Import libraries

library(ggplot2) # plot
library(caret) # train_split_test
## Loading required package: lattice
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggmosaic) # mosaic plot
library(ggcorrplot) # correlation plot
library(gridExtra)  # For combining multiple plots horizontally
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
library(tidyr)
library(DescTools)
## 
## Attaching package: 'DescTools'
## The following objects are masked from 'package:caret':
## 
##     MAE, RMSE
library(MASS)
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
library(ggfortify) # autoplot of survival curve
library(survival) # KM estimator
## 
## Attaching package: 'survival'
## The following object is masked from 'package:caret':
## 
##     cluster
library(survminer)
## Loading required package: ggpubr
## 
## Attaching package: 'survminer'
## The following object is masked from 'package:survival':
## 
##     myeloma
library(timereg)
library(riskRegression)
## riskRegression version 2023.12.21
library(randomForestSRC)
## 
##  randomForestSRC 3.3.1 
##  
##  Type rfsrc.news() to see new features, changes, and bug fixes. 
## 
library(LTRCforests)
## 
## Attaching package: 'LTRCforests'
## The following object is masked from 'package:base':
## 
##     print

Read dataset

df <- read.csv('hiv.csv', header = TRUE, sep = ',')
# View(df)
head(df)
##   subject  time death       cd4 time_obs treatment  sex prev_infection
## 1       1 16.97     0 10.677078        0       ddC male           AIDS
## 2       1 16.97     0  8.426150        6       ddC male           AIDS
## 3       1 16.97     0  9.433981       12       ddC male           AIDS
## 4       2 19.00     0  6.324555        0       ddI male         noAIDS
## 5       2 19.00     0  8.124038        6       ddI male         noAIDS
## 6       2 19.00     0  4.582576       12       ddI male         noAIDS
##           azt
## 1 intolerance
## 2 intolerance
## 3 intolerance
## 4 intolerance
## 5 intolerance
## 6 intolerance
num_vars = c('time', 'cd4', 'time_obs')
cat_vars = c('death', 'treatment', 'sex', 'prev_infection', 'azt')

Check for missing values

# function return None
get_information <- function(df){
  # brief information of dataframe from library(dplyr)
  glimpse(df)
  
  # init variables for print
  dimension = dim(df)
  missing_val_count = sum(is.na(df))
  column_names = colnames(df)
  distinct_subj = length(unique(df$subject))
  
  # numerical and categorical variables
  num_vars = c('time', 'cd4', 'time_obs')
  cat_vars = c('death', 'treatment', 'sex', 'prev_infection', 'azt')
  
  # visualize result
  cat("\nThe dataframe has", dimension[1], "rows and", dimension[2], "columns\n")
  cat("Total missing values:", missing_val_count, "\n")
  cat("Duplicate rows count:", sum(duplicated(df)), "\n") #sum() only counts TRUE values
  cat("Distinct subjects count in the study:", distinct_subj, "\n")
  
  for (var in cat_vars){
    #df$var will treat var as a literal string, use [[]] to reference the column dynamically by its name
    cat("Distinct values of variable", var, ":", unique(df[[var]]), "\n") 
  }
} 

get_information(df)
## Rows: 1,405
## Columns: 9
## $ subject        <int> 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6…
## $ time           <dbl> 16.97, 16.97, 16.97, 19.00, 19.00, 19.00, 19.00, 18.53,…
## $ death          <int> 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1…
## $ cd4            <dbl> 10.677078, 8.426150, 9.433981, 6.324555, 8.124038, 4.58…
## $ time_obs       <int> 0, 6, 12, 0, 6, 12, 18, 0, 2, 6, 0, 2, 6, 12, 0, 2, 6, …
## $ treatment      <chr> "ddC", "ddC", "ddC", "ddI", "ddI", "ddI", "ddI", "ddI",…
## $ sex            <chr> "male", "male", "male", "male", "male", "male", "male",…
## $ prev_infection <chr> "AIDS", "AIDS", "AIDS", "noAIDS", "noAIDS", "noAIDS", "…
## $ azt            <chr> "intolerance", "intolerance", "intolerance", "intoleran…
## 
## The dataframe has 1405 rows and 9 columns
## Total missing values: 0 
## Duplicate rows count: 0 
## Distinct subjects count in the study: 467 
## Distinct values of variable death : 0 1 
## Distinct values of variable treatment : ddC ddI 
## Distinct values of variable sex : male female 
## Distinct values of variable prev_infection : AIDS noAIDS 
## Distinct values of variable azt : intolerance failure

The data has no duplicate rows or missing values.

Check consistency of dataset

# check if a categorical variable is consistent for an individual
# Alert "not consistent" otherwise return nothing
is_consistent <- function(df_ind, var){
  distinct_val = unique(df_ind$var)
  if (length(distinct_val) > 1){
    cat(var, "is not consistent for subject", unique(df_ind$subject), "!!!!")
  } 
}


# get all subjects
subjects <- unique(df$subject)

# check if each categorical variable and for each subject
# print if not consistent
for (cat in cat_vars){
    for (sub in subjects){
    df_sub = df[df$subject == sub, ]
    is_consistent(df_sub, cat)
  }
}

No printing alertl. There is no data entry error for this dataset, so we are good to go!

Reformulate data

Although variable “death” is of type int, but its definition is the life indicator. Hence, we will change its type as we perceive it as a categorical variable. Plus, we will factorize the chr type variables.

# encode variable death
encode_death <- function(df){
  # replace column 'death' with second argument as a condition, 0 to 'censoring' and 1 to 'death'
  df$death = replace(df$death, df$death == 0, 'censoring')
  df$death = replace(df$death, df$death == 1, 'death')
  df$death = factor(df$death)
  return (df)
}
# copy dataframe
df_new <- df

# call encode function from function definition section. 0 = censored, 1 = death
df_new <- encode_death(df_new)

# death is already factorized in function encode_death()
#df_new <- df_new %>% 
#mutate(
#  treatment = factor(treatment),
#  sex = factor(sex),
#  prev_infection = factor(prev_infection),
#  azt = factor(azt)
#  )

get_information(df_new)
## Rows: 1,405
## Columns: 9
## $ subject        <int> 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6…
## $ time           <dbl> 16.97, 16.97, 16.97, 19.00, 19.00, 19.00, 19.00, 18.53,…
## $ death          <fct> censoring, censoring, censoring, censoring, censoring, …
## $ cd4            <dbl> 10.677078, 8.426150, 9.433981, 6.324555, 8.124038, 4.58…
## $ time_obs       <int> 0, 6, 12, 0, 6, 12, 18, 0, 2, 6, 0, 2, 6, 12, 0, 2, 6, …
## $ treatment      <chr> "ddC", "ddC", "ddC", "ddI", "ddI", "ddI", "ddI", "ddI",…
## $ sex            <chr> "male", "male", "male", "male", "male", "male", "male",…
## $ prev_infection <chr> "AIDS", "AIDS", "AIDS", "noAIDS", "noAIDS", "noAIDS", "…
## $ azt            <chr> "intolerance", "intolerance", "intolerance", "intoleran…
## 
## The dataframe has 1405 rows and 9 columns
## Total missing values: 0 
## Duplicate rows count: 0 
## Distinct subjects count in the study: 467 
## Distinct values of variable death : 1 2 
## Distinct values of variable treatment : ddC ddI 
## Distinct values of variable sex : male female 
## Distinct values of variable prev_infection : AIDS noAIDS 
## Distinct values of variable azt : intolerance failure

Exploratory Data Analysis (EDA)

From this section, we will use the modified dataframe (df_new) without affecting the original one.

Occurrence of each level of different categorical variables

# get unique row by remove duplicate rows to get info on categorical variables
df_unique <- df_new %>%
  group_by(subject) %>%
  slice_min(time_obs) %>%
  ungroup()

# count occurrence of each level of each categorical variable
table(df_unique$death)
## 
## censoring     death 
##       279       188
table(df_unique$sex)
## 
## female   male 
##     45    422
table(df_unique$treatment)
## 
## ddC ddI 
## 237 230
table(df_unique$prev_infection)
## 
##   AIDS noAIDS 
##    307    160
table(df_unique$azt)
## 
##     failure intolerance 
##         175         292

Numerical analysis

Statistics summary

summary(subset(df_new, select = num_vars))
##       time            cd4            time_obs     
##  Min.   : 0.47   Min.   : 0.000   Min.   : 0.000  
##  1st Qu.:12.23   1st Qu.: 3.162   1st Qu.: 0.000  
##  Median :14.07   Median : 5.477   Median : 2.000  
##  Mean   :13.89   Mean   : 7.023   Mean   : 4.214  
##  3rd Qu.:17.00   3rd Qu.:10.440   3rd Qu.: 6.000  
##  Max.   :21.40   Max.   :24.125   Max.   :18.000

Histogram

# looping and plot for each numerical variables
for (var in num_vars) {
  # build each layer separately for plot
  main <- ggplot(data = df_new, mapping = aes_string(x = var))
  type <- geom_histogram(aes(y = ..density..), binwidth = 2, alpha = 0.85) #aes(y = ..density..) normalize data on the same scale as histogram 
  density_curve <- geom_density(aes_string(x = var), color = "red", linewidth = 1)
  title <- labs(title = paste("Histogram of", var), x = var, y = "frequency")
  theme <- theme_gray()
  # combine layers
  graph <- main + type + density_curve + title + theme
  # display plot
  show(graph)
}
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

cd4 is positively skewed. So, the mean is greater than the median, which in turn is greater than the mode (mean > median > mode). The higher values create a tail extending to the right, which indicates that there is only few people who have significant amount of cd4 cells (healthy). This is often more appropriate to use non-parametric statistical methods.

Scatter plot for cd4 by different time_obs

main <- ggplot(data = df_new, mapping = aes(x = time_obs, y = cd4))
type <- geom_point(color = "red", alpha = 0.2)
title <- labs(title = paste("Scatter plot of cd4 against time_obs"), x = 'time_obs', y = "cd4 cells count")
theme <- theme_gray()
# combine layers
graph <- main + type + type + title + theme
# display plot
show(graph)

Visibly, there are not many subjects who reached 20 values of cd4. At time_obs 0 (start of the study), there is not a single subject who had cd4 cells over 20 but we can observe higher cd4 (above 20) later on, which potentially indicates a positive progress of the treatment.

Boxplot

# plot each numerical var, group by each categorical var
for (num in num_vars){
  for (cat in cat_vars){
    # build each layer separately for plot
    main <- ggplot(data = df_new, mapping = aes_string(x = cat, y = num))
    type <- geom_boxplot(fill = 'grey', color = 'black') 
    title <- labs(title = paste("Boxplot of", num, "against", cat), x = cat, y = num)
    theme <- theme_gray()
    # combine layers
    graph <- main + type + title + theme
    # display plot
    show(graph)
  }
}

# Plot cd4, group by each categorical var
# Reshape data to long format for categorical variables
tmp <- df_new %>%
  pivot_longer(cols = cat_vars, names_to = "category", values_to = "category_value")
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
##   # Was:
##   data %>% select(cat_vars)
## 
##   # Now:
##   data %>% select(all_of(cat_vars))
## 
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Plot with the same category levels grouped together on the x-axis
ggplot(tmp, aes(x = category_value, y = cd4, fill = category)) +
  geom_boxplot(position = position_dodge(width = 0.75), color = 'black') +
  labs(title = "Boxplot of CD4 Count across Categorical Variables",
       x = "Categorical Variables",
       y = "CD4 Count") +
  theme_gray() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Here, from the boxplot of cd4 against each categorical variable, ddI treatment seems to have slightly higher mean of cd4 cells count than ddC treatement. Also, the whisker is higher as well with only one outlier with higest cd4 cells count, approaching 25 of cd4 cells count.

Female group seems to have higher cd4 cells count than male group with slightly higher mean as well.

Logically, people without previous AIDS infection have much higher cd4 cells count. Notice that there are many points outside AIDS group whisker which indicates a possible positive progression of the treatment over time.

Again, it is logical that people who did not fail to tolerate the AZT therapy have higher cd4 cells count (healthier).

Categorical analysis

Mosaic plot

Each categorical variable will be shown separately with survival status ($death) using mosaic plot, focusing on univariate relationships which makes it easier to see any clear differences in survival proportions.

# x aesthetic doesn’t directly correspond to the x-axis as in typical ggplot2
# x defines the variable that will be split horizontally in the mosaic, while fill determines how the variable is stacked
for (cat in cat_vars[-1]){ #cat_vars[-1] removes "death" as it is the first element
  # build layers for ggplot
  main <- ggplot(df_new) 
  type <- geom_mosaic(mapping = aes_string(x = paste("product(", cat, ")"), fill = "death")) #gg_mosaic can't recognize cat, paste() is needed
  title <- labs(title = paste("Mosaic Plot of Survival Status (death) vs.", cat))
  theme <- theme_minimal()
  # combine layers
  graph <- main + type + title + theme
  # display plot
  show(graph)
}
## Warning: The `scale_name` argument of `continuous_scale()` is deprecated as of ggplot2
## 3.5.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `trans` argument of `continuous_scale()` is deprecated as of ggplot2 3.5.0.
## ℹ Please use the `transform` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: `unite_()` was deprecated in tidyr 1.2.0.
## ℹ Please use `unite()` instead.
## ℹ The deprecated feature was likely used in the ggmosaic package.
##   Please report the issue at <https://github.com/haleyjeppson/ggmosaic>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

x-axis represents the categorical variables, while y-axis measuring the survival status ($death).

  • We can observe horizontal line for treatment group ddC and ddI, which indicates that they are barely different.
  • Same for sex which suggests really small amount of dependency (arguably no difference between two groups).
  • We can see for people without previous AIDS infection (noAIDS), most of the data are censored which suggests a smaller amount of death compares to people with AIDS infection group.
  • Same as azt, since the mosaic plot bars are not equal, we can conclude that the death does depend on whether people failed AZT or not (failure is worse than intolerance).

Now we want to see if the conditional mosaic plot makes any difference. Since the aim of the study is to compare the efficacy and safety of the alternative antiretroviral drugs (treatment), each categorical variable will be shown against death proportion conditional treatment.

Conditional mosaic plot

for (cat in setdiff(cat_vars, c('death', 'treatment'))){ #remove death and treatment
  # build layers for ggplot
  main <- ggplot(df_new) 
  type <- geom_mosaic(mapping = aes_string(x = paste("product(treatment)"), conds = paste("product(", cat, ")"), fill = "death")) 
  title <- labs(title = paste("Mosaic Plot of treatment against death and", cat, "conditions"))
  theme <- theme_minimal()
  # combine layers
  graph <- main + type + title + theme
  # display plot
  show(graph)
}

  • There is no sight of significant effectiveness of the treatment though we can see that for female group ddC works slightly better than ddI. Same for male group.
  • For prev_infection condition, there is no difference between the treatment if the subject had AIDS infection before. However, if the subject had no previous infection, ddC treatment is better than ddI as we can see on the right side that the censoring proportion is larger than death.
  • Once again, ddC treatment shows a better survival proportion until the end of the study than ddI. But, what is interesting is that if they failed AZT therapy, it maybe slightly more effective with ddI treatment.

The conclusion above is a only preliminary observation. To confirm, we would need statistical tests to verify.

Relationship between covriates

Since there are a mixture of numerical and categorical in the dataset. First, we will need to transform the data to entirely numerical, by creating the corresponding dummy variables.

# encode categorical variables to numerical for correlation matrix
# note that variable 'death' was already originally int of 0,1
# as.numeric as repalce treat 0,1 as chr
# -1 because it returns 1,2 instead of 0,1
encode_cat_vars <- function(df) {
  # Encode treatment: ddC = 0, ddI = 1
  df$treatment <- as.numeric(factor(df$treatment, levels = c('ddC', 'ddI'), labels = c(0, 1))) - 1
  # Encode sex: male = 0, female = 1
  df$sex <- as.numeric(factor(df$sex, levels = c('male', 'female'), labels = c(0, 1))) - 1
  # Encode previous infection: noAIDS = 0, AIDS = 1
  df$prev_infection <- as.numeric(factor(df$prev_infection, levels = c('noAIDS', 'AIDS'), labels = c(0, 1))) - 1
  # Encode azt tolerance: intolerance = 0, failure = 1
  df$azt <- as.numeric(factor(df$azt, levels = c('intolerance', 'failure'), labels = c(0, 1))) - 1
  return(df)
}

# copy from df, as death was originally a numerical dichotomous variable 0, 1
df_numeric <- df

# transform categorical to numerical covariates 
df_numeric <- encode_cat_vars(df_numeric)

# get detail infromation of encoded (numerical) dataframe
get_information(df_numeric)
## Rows: 1,405
## Columns: 9
## $ subject        <int> 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6…
## $ time           <dbl> 16.97, 16.97, 16.97, 19.00, 19.00, 19.00, 19.00, 18.53,…
## $ death          <int> 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1…
## $ cd4            <dbl> 10.677078, 8.426150, 9.433981, 6.324555, 8.124038, 4.58…
## $ time_obs       <int> 0, 6, 12, 0, 6, 12, 18, 0, 2, 6, 0, 2, 6, 12, 0, 2, 6, …
## $ treatment      <dbl> 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0…
## $ sex            <dbl> 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1…
## $ prev_infection <dbl> 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ azt            <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## 
## The dataframe has 1405 rows and 9 columns
## Total missing values: 0 
## Duplicate rows count: 0 
## Distinct subjects count in the study: 467 
## Distinct values of variable death : 0 1 
## Distinct values of variable treatment : 0 1 
## Distinct values of variable sex : 0 1 
## Distinct values of variable prev_infection : 1 0 
## Distinct values of variable azt : 0 1
# calculate correlation matrix 
# remove subject column from dataframe in the calculation
corr <- cor(subset(df_numeric, select = -c(subject)))
cat("Correlation matrix\n")
## Correlation matrix
corr
##                       time        death         cd4     time_obs    treatment
## time            1.00000000 -0.631678042  0.20953058  0.299454363 -0.033305208
## death          -0.63167804  1.000000000 -0.31603946 -0.261888032  0.032063142
## cd4             0.20953058 -0.316039460  1.00000000 -0.034040100  0.059119338
## time_obs        0.29945436 -0.261888032 -0.03404010  1.000000000 -0.006311045
## treatment      -0.03330521  0.032063142  0.05911934 -0.006311045  1.000000000
## sex            -0.05301084 -0.007406408  0.06930391 -0.034402852 -0.011813703
## prev_infection -0.25176982  0.292065478 -0.43882257 -0.107358850 -0.016360947
## azt            -0.09589065  0.203362331 -0.26360269 -0.047745200 -0.037125776
##                         sex prev_infection         azt
## time           -0.053010836    -0.25176982 -0.09589065
## death          -0.007406408     0.29206548  0.20336233
## cd4             0.069303914    -0.43882257 -0.26360269
## time_obs       -0.034402852    -0.10735885 -0.04774520
## treatment      -0.011813703    -0.01636095 -0.03712578
## sex             1.000000000    -0.06279221 -0.10204392
## prev_infection -0.062792207     1.00000000  0.56551418
## azt            -0.102043916     0.56551418  1.00000000
cat("\n")
# computes a matrix of correlation p-values: to mark insignificant cell
pval_mat <- cor_pmat(subset(df_numeric, select = -c(subject)))
cat("Matrix of correlation p-values\n")
## Matrix of correlation p-values
pval_mat
##                         time         death          cd4     time_obs  treatment
## time            0.000000e+00 2.506817e-157 2.102318e-15 1.682446e-30 0.21216839
## death          2.506817e-157  0.000000e+00 5.851545e-34 1.819616e-23 0.22972310
## cd4             2.102318e-15  5.851545e-34 0.000000e+00 2.022490e-01 0.02669454
## time_obs        1.682446e-30  1.819616e-23 2.022490e-01 0.000000e+00 0.81316048
## treatment       2.121684e-01  2.297231e-01 2.669454e-02 8.131605e-01 0.00000000
## sex             4.696108e-02  7.814933e-01 9.361728e-03 1.974790e-01 0.65817210
## prev_infection  9.375725e-22  4.964164e-29 3.316089e-67 5.524671e-05 0.54003639
## azt             3.189540e-04  1.398728e-14 9.169339e-24 7.360249e-02 0.16427437
##                         sex prev_infection           azt
## time           0.0469610828   9.375725e-22  3.189540e-04
## death          0.7814932918   4.964164e-29  1.398728e-14
## cd4            0.0093617278   3.316089e-67  9.169339e-24
## time_obs       0.1974790305   5.524671e-05  7.360249e-02
## treatment      0.6581721030   5.400364e-01  1.642744e-01
## sex            0.0000000000   1.857815e-02  1.273401e-04
## prev_infection 0.0185781474   0.000000e+00 1.468971e-119
## azt            0.0001273401  1.468971e-119  0.000000e+00

Below is a representation of correlation matrix, which a mark ‘X’ indicates the no significant coefficient (big p-values)

ggcorrplot(corr, lab = TRUE, outline.col = "black", p.mat = pval_mat)

We can observe that: * azt positively correlate with prev_infection. * treatment only barely correlate with cd4. * cd4 negatively correlate with prev_infection. (highest) * death correlate with time is logic.

Overall, we don’t observe an extreme correlation between covariates, though the highest positive coefficient is 0.57 between azt and prev_infection and the highest negative coefficient is -0.63 between death and time.

Kaplan-Meier analysis

We now represent graphically the survival functions in the subgroups defined by the categorical variables. We will use “df” dataframe, the original dataframe since the Surv: survival object takes status type as integer 0, 1.

km_fit <- survfit(Surv(time, death) ~ 1, data = df)
autoplot(km_fit)

for (cat in cat_vars[-1]) { # Exclude "death"
  # Create Kaplan-Meier survival fit
  cat('++++++++++++++++++++++++++', cat, '++++++++++++++++++++++++++\n')
  KMfit <- survfit(Surv(time, death) ~ get(cat), data = df) 
  print(KMfit)
  show(autoplot(KMfit))
  cat('\n')
}
## ++++++++++++++++++++++++++ treatment ++++++++++++++++++++++++++
## $n
## [1] 717 688
## 
## $time
##   [1]  0.77  1.03  1.07  1.43  1.90  2.00  2.17  2.40  2.47  2.70  3.00  3.20
##  [13]  3.30  3.37  3.40  3.43  3.57  3.90  3.97  4.57  4.67  4.93  4.97  5.23
##  [25]  5.37  5.57  5.90  6.00  7.10  7.17  7.67  7.70  7.73  7.93  7.97  8.00
##  [37]  8.33  8.43  8.47  8.73  8.80  9.37  9.60  9.63  9.77 10.03 10.07 10.30
##  [49] 10.33 10.40 10.57 10.70 10.80 11.00 11.03 11.07 11.17 11.30 11.57 11.67
##  [61] 11.90 12.07 12.20 12.23 12.27 12.30 12.33 12.37 12.43 12.47 12.50 12.53
##  [73] 12.57 12.67 12.70 12.73 12.90 12.97 13.00 13.03 13.10 13.20 13.23 13.43
##  [85] 13.50 13.60 13.70 13.73 13.83 13.90 13.93 14.07 14.10 14.13 14.17 14.30
##  [97] 14.33 14.40 14.43 14.60 14.63 14.70 14.87 15.03 15.07 15.10 15.17 15.37
## [109] 15.50 15.53 15.70 15.77 15.80 15.90 15.97 16.03 16.17 16.23 16.27 16.30
## [121] 16.40 16.47 16.50 16.63 16.67 16.70 16.87 16.97 17.00 17.03 17.10 17.20
## [133] 17.23 17.27 17.33 17.37 17.43 17.57 17.63 17.67 17.70 17.80 17.83 17.87
## [145] 17.93 18.07 18.13 18.17 18.33 18.37 18.50 18.57 18.60 18.63 18.77 18.87
## [157] 18.97 19.07 19.20 19.27 19.57 19.80 19.93 20.23 20.27 20.67 20.87  0.47
## [169]  0.90  1.13  1.30  1.63  1.70  1.83  2.00  2.03  2.13  2.57  2.60  2.73
## [181]  3.13  3.20  3.30  3.63  3.83  4.10  4.20  4.33  4.53  4.60  5.03  5.07
## [193]  5.10  5.43  5.53  6.07  6.13  6.30  6.60  6.63  6.87  6.90  7.03  7.17
## [205]  7.30  7.40  7.57  7.83  7.93  8.07  8.13  8.17  8.30  8.47  9.07  9.33
## [217]  9.37  9.57  9.67  9.73  9.80  9.93 10.23 10.30 10.60 10.63 10.87 10.93
## [229] 11.07 11.13 11.20 11.30 11.47 11.50 11.60 11.63 11.93 12.20 12.23 12.27
## [241] 12.30 12.33 12.43 12.47 12.50 12.53 12.63 12.67 12.70 12.73 12.77 12.93
## [253] 13.00 13.03 13.13 13.20 13.27 13.30 13.37 13.40 13.47 13.50 13.60 13.87
## [265] 13.93 14.07 14.13 14.17 14.20 14.33 14.40 14.43 14.57 14.60 14.63 14.83
## [277] 14.87 14.90 15.03 15.07 15.10 15.13 15.27 15.33 15.47 15.57 15.60 15.93
## [289] 15.97 16.00 16.17 16.20 16.23 16.43 16.47 16.50 16.63 16.73 16.93 16.97
## [301] 17.17 17.20 17.37 17.40 17.80 17.83 17.87 17.93 18.03 18.10 18.13 18.17
## [313] 18.37 18.40 18.53 18.57 18.80 19.00 19.03 19.53 19.57 19.70 19.77 19.80
## [325] 20.27 20.40 20.50 20.63 21.13 21.40
## 
## $n.risk
##   [1] 717 716 715 713 711 710 709 707 706 703 702 701 699 698 696 694 693 691
##  [19] 689 688 687 686 685 683 681 679 675 673 671 668 665 663 661 658 656 652
##  [37] 650 648 647 645 642 639 637 634 631 628 625 622 619 616 613 610 605 602
##  [55] 600 597 595 593 590 588 585 583 580 567 548 538 534 526 523 515 507 505
##  [73] 493 490 486 474 470 467 463 459 454 450 432 424 420 409 405 401 393 391
##  [91] 374 370 367 363 359 355 351 343 335 332 328 321 317 314 310 308 302 298
## [109] 294 290 286 283 281 278 274 265 246 242 231 228 221 218 214 211 208 204
## [127] 200 196 190 186 184 180 176 173 169 165 157 153 149 145 136 128 121 117
## [145] 113 109 104  90  86  81  76  73  70  65  63  60  58  53  50  45  36  32
## [163]  24  21  17  10   5 688 687 686 685 684 683 682 681 680 679 678 677 674
## [181] 673 670 669 667 666 665 663 662 660 658 656 655 653 651 649 647 645 642
## [199] 640 638 637 636 634 632 627 624 621 619 618 615 612 609 607 604 601 599
## [217] 596 594 588 586 583 580 575 567 566 563 561 559 556 553 551 548 545 544
## [235] 539 536 533 528 518 501 489 478 474 470 461 456 451 448 442 432 428 420
## [253] 413 409 405 401 399 396 391 382 378 371 367 363 352 340 333 329 325 317
## [271] 311 303 302 298 294 291 288 284 280 272 270 268 264 260 254 250 236 228
## [289] 221 213 210 207 201 197 193 185 184 180 176 168 164 160 154 150 144 140
## [307] 133 131 123 114 109 105  96  83  75  72  65  60  56  51  46  41  36  32
## [325]  27  22  17  12  10   4
## 
## $n.event
##   [1] 1 1 2 2 1 1 1 1 3 1 1 2 1 2 2 1 2 2 1 1 1 1 2 2 2 4 2 2 3 3 2 2 3 2 4 2 2
##  [38] 1 2 3 3 2 3 3 3 3 3 3 3 3 3 5 3 2 3 2 2 3 2 3 2 3 0 3 0 0 0 3 0 0 0 0 0 0
##  [75] 0 0 0 0 0 0 4 0 0 0 0 3 0 0 0 4 0 0 0 0 0 0 0 0 0 0 3 4 3 0 0 2 4 0 0 0 3
## [112] 0 0 0 0 0 0 0 3 0 3 0 0 3 0 0 0 0 0 2 0 0 0 4 0 0 0 0 0 0 0 3 0 0 0 5 0 0
## [149] 0 0 0 0 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 3 1 3 1 2 1 1
## [186] 2 1 2 2 2 1 2 2 2 2 2 3 2 2 1 1 2 2 5 3 3 2 1 0 3 3 2 3 3 2 3 2 6 2 3 3 5
## [223] 8 1 3 2 2 3 3 2 3 3 1 5 3 3 5 6 0 2 3 0 0 3 0 1 3 3 3 0 0 0 0 0 0 2 0 5 0
## [260] 0 0 0 0 3 0 0 4 0 0 0 0 1 0 0 0 0 0 0 0 2 0 0 0 2 4 2 0 0 0 0 0 0 0 0 0 0
## [297] 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 
## $n.censor
##   [1]  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [51]  0  0  0  0  0  0  0  0  0  0  0  0 13 16 10  4  8  0  8  8  2 12  3  4 12
##  [76]  4  3  4  4  5  0 18  8  4 11  1  4  8  2 13  4  3  4  4  4  4  8  8  3  4
## [101]  4  0  0  4  2  4  0  4  4  4  0  2  3  4  9 19  4 11  0  7  0  4  3  0  4
## [126]  4  4  6  4  0  4  4  3  0  4  8  4  4  4  9  8  4  4  4  4  0 14  4  5  5
## [151]  3  3  5  0  3  2  5  0  5  9  4  8  3  4  7  5  5  0  0  0  0  0  0  1  0
## [176]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [201]  0  0  0  0  0  0  0  0  3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [226]  0  0  0  0  0  0  0  0  0  0  0  0  4 17 10  8  4  4  6  5  4  0  3  7  4
## [251]  8  7  4  4  4  0  3  0  9  4  7  4  4  8 12  7  0  4  8  6  8  0  4  4  3
## [276]  3  4  4  8  0  2  4  4  4  0 12  8  7  8  3  3  6  4  4  8  1  0  4  8  4
## [301]  4  6  4  6  4  7  2  8  9  5  4  9 13  8  0  7  5  4  5  5  5  5  4  5  5
## [326]  5  5  2  6  4
## 
## $surv
##   [1] 0.9986053 0.9972106 0.9944212 0.9916318 0.9902371 0.9888424 0.9874477
##   [8] 0.9860510 0.9818610 0.9804643 0.9790677 0.9762743 0.9748776 0.9720843
##  [15] 0.9692910 0.9678943 0.9651009 0.9623076 0.9609109 0.9595142 0.9581176
##  [22] 0.9567209 0.9539276 0.9511342 0.9483409 0.9427542 0.9399608 0.9371675
##  [29] 0.9329775 0.9287874 0.9259941 0.9232007 0.9190107 0.9162174 0.9106307
##  [36] 0.9078373 0.9050440 0.9036473 0.9008540 0.8966640 0.8924739 0.8896806
##  [43] 0.8854906 0.8813006 0.8771105 0.8729205 0.8687305 0.8645405 0.8603505
##  [50] 0.8561605 0.8519704 0.8449871 0.8407971 0.8380037 0.8338137 0.8310203
##  [57] 0.8282270 0.8240370 0.8212436 0.8170536 0.8142603 0.8100702 0.8100702
##  [64] 0.8057842 0.8057842 0.8057842 0.8057842 0.8011884 0.8011884 0.8011884
##  [71] 0.8011884 0.8011884 0.8011884 0.8011884 0.8011884 0.8011884 0.8011884
##  [78] 0.8011884 0.8011884 0.8011884 0.7941295 0.7941295 0.7941295 0.7941295
##  [85] 0.7941295 0.7883046 0.7883046 0.7883046 0.7883046 0.7802401 0.7802401
##  [92] 0.7802401 0.7802401 0.7802401 0.7802401 0.7802401 0.7802401 0.7802401
##  [99] 0.7802401 0.7802401 0.7731038 0.7634701 0.7562448 0.7562448 0.7562448
## [106] 0.7513341 0.7413827 0.7413827 0.7413827 0.7413827 0.7336059 0.7336059
## [113] 0.7336059 0.7336059 0.7336059 0.7336059 0.7336059 0.7336059 0.7240786
## [120] 0.7240786 0.7142495 0.7142495 0.7142495 0.7040943 0.7040943 0.7040943
## [127] 0.7040943 0.7040943 0.7040943 0.6965233 0.6965233 0.6965233 0.6965233
## [134] 0.6804188 0.6804188 0.6804188 0.6804188 0.6804188 0.6804188 0.6804188
## [141] 0.6804188 0.6644714 0.6644714 0.6644714 0.6644714 0.6339911 0.6339911
## [148] 0.6339911 0.6339911 0.6339911 0.6339911 0.6339911 0.6339911 0.6144837
## [155] 0.6144837 0.6144837 0.6144837 0.5797016 0.5797016 0.5797016 0.5797016
## [162] 0.5797016 0.5797016 0.5797016 0.5797016 0.5797016 0.5797016 0.9985465
## [169] 0.9970930 0.9956395 0.9941860 0.9927326 0.9912791 0.9912791 0.9898234
## [176] 0.9883678 0.9869122 0.9854566 0.9810897 0.9796341 0.9752672 0.9738116
## [183] 0.9709004 0.9694447 0.9679891 0.9650779 0.9636222 0.9607110 0.9577997
## [190] 0.9548885 0.9534329 0.9505216 0.9476104 0.9446991 0.9417879 0.9388767
## [197] 0.9345098 0.9315985 0.9286873 0.9272317 0.9257760 0.9228648 0.9199536
## [204] 0.9126754 0.9083086 0.9039417 0.9010305 0.8995748 0.8995748 0.8951867
## [211] 0.8907985 0.8878731 0.8834849 0.8790967 0.8761713 0.8717831 0.8688576
## [218] 0.8600813 0.8571559 0.8527677 0.8483795 0.8410659 0.8293641 0.8279014
## [225] 0.8235132 0.8205878 0.8176623 0.8132742 0.8088860 0.8059605 0.8015724
## [232] 0.7971842 0.7957215 0.7884079 0.7840197 0.7796315 0.7723179 0.7635416
## [239] 0.7635416 0.7604935 0.7558279 0.7558279 0.7558279 0.7510035 0.7510035
## [246] 0.7493565 0.7443719 0.7393873 0.7343688 0.7343688 0.7343688 0.7343688
## [253] 0.7343688 0.7343688 0.7343688 0.7307061 0.7307061 0.7214800 0.7214800
## [260] 0.7214800 0.7214800 0.7214800 0.7214800 0.7155174 0.7155174 0.7155174
## [267] 0.7069226 0.7069226 0.7069226 0.7069226 0.7069226 0.7045895 0.7045895
## [274] 0.7045895 0.7045895 0.7045895 0.7045895 0.7045895 0.7045895 0.6994087
## [281] 0.6994087 0.6994087 0.6994087 0.6940286 0.6830990 0.6776342 0.6776342
## [288] 0.6776342 0.6776342 0.6776342 0.6776342 0.6776342 0.6776342 0.6776342
## [295] 0.6776342 0.6776342 0.6629031 0.6629031 0.6629031 0.6629031 0.6629031
## [302] 0.6629031 0.6629031 0.6629031 0.6629031 0.6629031 0.6629031 0.6629031
## [309] 0.6629031 0.6629031 0.6629031 0.6629031 0.6629031 0.6629031 0.6363869
## [316] 0.6363869 0.6363869 0.6363869 0.6363869 0.6363869 0.6363869 0.6363869
## [323] 0.6363869 0.6363869 0.6363869 0.6363869 0.6363869 0.6363869 0.6363869
## [330] 0.6363869
## 
## $std.err
##   [1] 0.001395674 0.001975161 0.002797214 0.003430688 0.003708175 0.003967001
##   [7] 0.004210610 0.004442148 0.005077124 0.005272903 0.005462198 0.005823852
##  [13] 0.005997236 0.006331168 0.006650133 0.006804669 0.007104934 0.007394653
##  [19] 0.007535944 0.007675035 0.007812044 0.007947081 0.008211634 0.008469407
##  [25] 0.008721017 0.009207799 0.009443844 0.009675487 0.010015392 0.010347052
##  [31] 0.010563982 0.010777819 0.011093193 0.011300103 0.011706597 0.011906453
##  [37] 0.012104212 0.012202341 0.012397164 0.012685995 0.012971018 0.013159058
##  [43] 0.013438346 0.013714523 0.013987808 0.014258404 0.014526497 0.014792260
##  [49] 0.015055853 0.015317423 0.015577110 0.016006081 0.016261354 0.016430726
##  [55] 0.016683643 0.016851539 0.017018893 0.017268970 0.017435090 0.017683433
##  [61] 0.017848472 0.018095304 0.018095304 0.018352690 0.018352690 0.018352690
##  [67] 0.018352690 0.018647424 0.018647424 0.018647424 0.018647424 0.018647424
##  [73] 0.018647424 0.018647424 0.018647424 0.018647424 0.018647424 0.018647424
##  [79] 0.018647424 0.018647424 0.019165215 0.019165215 0.019165215 0.019165215
##  [85] 0.019165215 0.019630891 0.019630891 0.019630891 0.019630891 0.020293015
##  [91] 0.020293015 0.020293015 0.020293015 0.020293015 0.020293015 0.020293015
##  [97] 0.020293015 0.020293015 0.020293015 0.020293015 0.020974963 0.021891971
## [103] 0.022569839 0.022569839 0.022569839 0.023035152 0.023980506 0.023980506
## [109] 0.023980506 0.023980506 0.024741263 0.024741263 0.024741263 0.024741263
## [115] 0.024741263 0.024741263 0.024741263 0.024741263 0.025866787 0.025866787
## [121] 0.027043664 0.027043664 0.027043664 0.028279242 0.028279242 0.028279242
## [127] 0.028279242 0.028279242 0.028279242 0.029294267 0.029294267 0.029294267
## [133] 0.029294267 0.031543098 0.031543098 0.031543098 0.031543098 0.031543098
## [139] 0.031543098 0.031543098 0.031543098 0.034387018 0.034387018 0.034387018
## [145] 0.034387018 0.040293172 0.040293172 0.040293172 0.040293172 0.040293172
## [151] 0.040293172 0.040293172 0.040293172 0.045955851 0.045955851 0.045955851
## [157] 0.045955851 0.056956261 0.056956261 0.056956261 0.056956261 0.056956261
## [163] 0.056956261 0.056956261 0.056956261 0.056956261 0.056956261 0.001454546
## [169] 0.002058537 0.002523022 0.002915464 0.003261974 0.003575932 0.003575932
## [175] 0.003866102 0.004136733 0.004391442 0.004632859 0.005295095 0.005499328
## [181] 0.006074193 0.006255143 0.006603702 0.006772002 0.006936707 0.007256317
## [187] 0.007411648 0.007714274 0.008007206 0.008291487 0.008430662 0.008703567
## [193] 0.008969772 0.009229873 0.009484385 0.009733761 0.010099055 0.010337239
## [199] 0.010571501 0.010687246 0.010802109 0.011029305 0.011253310 0.011800629
## [205] 0.012121164 0.012436417 0.012643868 0.012746823 0.012746823 0.013055733
## [211] 0.013360440 0.013561404 0.013859811 0.014154813 0.014349714 0.014639589
## [217] 0.014831281 0.015399529 0.015586849 0.015866036 0.016143208 0.016601074
## [223] 0.017324366 0.017414065 0.017682312 0.017860471 0.018038126 0.018303726
## [229] 0.018568346 0.018744259 0.019007439 0.019269863 0.019357183 0.019792746
## [235] 0.020053350 0.020313489 0.020746195 0.021264384 0.021264384 0.021451668
## [241] 0.021743906 0.021743906 0.021743906 0.022055963 0.022055963 0.022164955
## [247] 0.022497404 0.022829397 0.023165540 0.023165540 0.023165540 0.023165540
## [253] 0.023165540 0.023165540 0.023165540 0.023433786 0.023433786 0.024112954
## [259] 0.024112954 0.024112954 0.024112954 0.024112954 0.024112954 0.024584373
## [265] 0.024584373 0.024584373 0.025316044 0.025316044 0.025316044 0.025316044
## [271] 0.025316044 0.025530968 0.025530968 0.025530968 0.025530968 0.025530968
## [277] 0.025530968 0.025530968 0.025530968 0.026058846 0.026058846 0.026058846
## [283] 0.026058846 0.026624774 0.027782561 0.028357164 0.028357164 0.028357164
## [289] 0.028357164 0.028357164 0.028357164 0.028357164 0.028357164 0.028357164
## [295] 0.028357164 0.028357164 0.030412197 0.030412197 0.030412197 0.030412197
## [301] 0.030412197 0.030412197 0.030412197 0.030412197 0.030412197 0.030412197
## [307] 0.030412197 0.030412197 0.030412197 0.030412197 0.030412197 0.030412197
## [313] 0.030412197 0.030412197 0.038476711 0.038476711 0.038476711 0.038476711
## [319] 0.038476711 0.038476711 0.038476711 0.038476711 0.038476711 0.038476711
## [325] 0.038476711 0.038476711 0.038476711 0.038476711 0.038476711 0.038476711
## 
## $cumhaz
##   [1] 0.001394700 0.002791348 0.005588551 0.008393600 0.009800070 0.011208521
##   [7] 0.012618958 0.014033385 0.018282677 0.019705152 0.021129653 0.023982720
##  [13] 0.025413335 0.028278665 0.031152228 0.032593150 0.035479153 0.038373509
##  [19] 0.039824888 0.041278376 0.042733981 0.044191706 0.047111415 0.050039672
##  [25] 0.052976530 0.058867546 0.061830509 0.064802277 0.069273216 0.073764234
##  [31] 0.076771753 0.079788344 0.084326922 0.087366436 0.093463997 0.096531481
##  [37] 0.099608404 0.101151614 0.104242804 0.108893967 0.113566864 0.116696755
##  [43] 0.121406331 0.126138192 0.130892550 0.135669620 0.140469620 0.145292771
##  [49] 0.150139298 0.155009428 0.159903392 0.168100113 0.173058791 0.176381050
##  [55] 0.181381050 0.184731134 0.188092479 0.193151500 0.196541331 0.201643372
##  [61] 0.205062175 0.210207973 0.210207973 0.215498978 0.215498978 0.215498978
##  [67] 0.215498978 0.221202400 0.221202400 0.221202400 0.221202400 0.221202400
##  [73] 0.221202400 0.221202400 0.221202400 0.221202400 0.221202400 0.221202400
##  [79] 0.221202400 0.221202400 0.230012973 0.230012973 0.230012973 0.230012973
##  [85] 0.230012973 0.237347936 0.237347936 0.237347936 0.237347936 0.247578115
##  [91] 0.247578115 0.247578115 0.247578115 0.247578115 0.247578115 0.247578115
##  [97] 0.247578115 0.247578115 0.247578115 0.247578115 0.256724457 0.269185516
## [103] 0.278649238 0.278649238 0.278649238 0.285142745 0.298387778 0.298387778
## [109] 0.298387778 0.298387778 0.308877288 0.308877288 0.308877288 0.308877288
## [115] 0.308877288 0.308877288 0.308877288 0.308877288 0.321864301 0.321864301
## [121] 0.335438962 0.335438962 0.335438962 0.349656971 0.349656971 0.349656971
## [127] 0.349656971 0.349656971 0.349656971 0.360409660 0.360409660 0.360409660
## [133] 0.360409660 0.383531047 0.383531047 0.383531047 0.383531047 0.383531047
## [139] 0.383531047 0.383531047 0.383531047 0.406968547 0.406968547 0.406968547
## [145] 0.406968547 0.452840106 0.452840106 0.452840106 0.452840106 0.452840106
## [151] 0.452840106 0.452840106 0.452840106 0.483609337 0.483609337 0.483609337
## [157] 0.483609337 0.540213111 0.540213111 0.540213111 0.540213111 0.540213111
## [163] 0.540213111 0.540213111 0.540213111 0.540213111 0.540213111 0.001453488
## [169] 0.002909092 0.004366818 0.005826672 0.007288661 0.008752790 0.008752790
## [175] 0.010221218 0.011691807 0.013164561 0.014639487 0.019070802 0.020554481
## [181] 0.025012133 0.026504671 0.029494207 0.030993458 0.032494959 0.035502478
## [187] 0.037010774 0.040031922 0.043062225 0.046101738 0.047626129 0.050679564
## [193] 0.053742351 0.056814547 0.059896212 0.062987402 0.067638564 0.070753829
## [199] 0.073878829 0.075446227 0.077016086 0.080160740 0.083315314 0.091226707
## [205] 0.096011396 0.100819088 0.104039700 0.105655209 0.105655209 0.110533258
## [211] 0.115435218 0.118719291 0.123661630 0.128628517 0.131956304 0.136964652
## [217] 0.140320356 0.150421366 0.153822727 0.158942181 0.164087979 0.172708668
## [223] 0.186621712 0.188385380 0.193685733 0.197238131 0.200803194 0.206169920
## [229] 0.211565603 0.215182240 0.220626886 0.226101339 0.227936201 0.237127377
## [235] 0.242693240 0.248290255 0.257671118 0.269034755 0.269034755 0.273026770
## [241] 0.279161740 0.279161740 0.279161740 0.285544719 0.285544719 0.287737701
## [247] 0.294389586 0.301086014 0.307873345 0.307873345 0.307873345 0.307873345
## [253] 0.307873345 0.307873345 0.307873345 0.312860876 0.312860876 0.325487138
## [259] 0.325487138 0.325487138 0.325487138 0.325487138 0.325487138 0.333751601
## [265] 0.333751601 0.333751601 0.345763613 0.345763613 0.345763613 0.345763613
## [271] 0.345763613 0.349063943 0.349063943 0.349063943 0.349063943 0.349063943
## [277] 0.349063943 0.349063943 0.349063943 0.356416884 0.356416884 0.356416884
## [283] 0.356416884 0.364109192 0.379857224 0.387857224 0.387857224 0.387857224
## [289] 0.387857224 0.387857224 0.387857224 0.387857224 0.387857224 0.387857224
## [295] 0.387857224 0.387857224 0.409596354 0.409596354 0.409596354 0.409596354
## [301] 0.409596354 0.409596354 0.409596354 0.409596354 0.409596354 0.409596354
## [307] 0.409596354 0.409596354 0.409596354 0.409596354 0.409596354 0.409596354
## [313] 0.409596354 0.409596354 0.449596354 0.449596354 0.449596354 0.449596354
## [319] 0.449596354 0.449596354 0.449596354 0.449596354 0.449596354 0.449596354
## [325] 0.449596354 0.449596354 0.449596354 0.449596354 0.449596354 0.449596354
## 
## $std.chaz
##   [1] 0.001394700 0.001973782 0.002794277 0.003426680 0.003704091 0.003962831
##   [7] 0.004206348 0.004437788 0.005070778 0.005266519 0.005455770 0.005816823
##  [13] 0.005990166 0.006323539 0.006641975 0.006796476 0.007096238 0.007385475
##  [19] 0.007526735 0.007665792 0.007802765 0.007937765 0.008201857 0.008459185
##  [25] 0.008710360 0.009194911 0.009430587 0.009661867 0.010000738 0.010331401
##  [31] 0.010548006 0.010761522 0.011075946 0.011282548 0.011687213 0.011886786
##  [37] 0.012084263 0.012182402 0.012376940 0.012664902 0.012949070 0.013136838
##  [43] 0.013415285 0.013690631 0.013963095 0.014232878 0.014500166 0.014765131
##  [49] 0.015027930 0.015288713 0.015547616 0.015973904 0.016228425 0.016397576
##  [55] 0.016649739 0.016817412 0.016984542 0.017233859 0.017399752 0.017647332
##  [61] 0.017812143 0.018058207 0.018058207 0.018314760 0.018314760 0.018314760
##  [67] 0.018314760 0.018608424 0.018608424 0.018608424 0.018608424 0.018608424
##  [73] 0.018608424 0.018608424 0.018608424 0.018608424 0.018608424 0.018608424
##  [79] 0.018608424 0.018608424 0.019122761 0.019122761 0.019122761 0.019122761
##  [85] 0.019122761 0.019586063 0.019586063 0.019586063 0.019586063 0.020242974
##  [91] 0.020242974 0.020242974 0.020242974 0.020242974 0.020242974 0.020242974
##  [97] 0.020242974 0.020242974 0.020242974 0.020242974 0.020920401 0.021828484
## [103] 0.022501927 0.022501927 0.022501927 0.022965616 0.023901407 0.023901407
## [109] 0.023901407 0.023901407 0.024656720 0.024656720 0.024656720 0.024656720
## [115] 0.024656720 0.024656720 0.024656720 0.024656720 0.025771587 0.025771587
## [121] 0.026936936 0.026936936 0.026936936 0.028159944 0.028159944 0.028159944
## [127] 0.028159944 0.028159944 0.028159944 0.029168349 0.029168349 0.029168349
## [133] 0.029168349 0.031375822 0.031375822 0.031375822 0.031375822 0.031375822
## [139] 0.031375822 0.031375822 0.031375822 0.034169397 0.034169397 0.034169397
## [145] 0.034169397 0.039854582 0.039854582 0.039854582 0.039854582 0.039854582
## [151] 0.039854582 0.039854582 0.039854582 0.045406613 0.045406613 0.045406613
## [157] 0.045406613 0.055944224 0.055944224 0.055944224 0.055944224 0.055944224
## [163] 0.055944224 0.055944224 0.055944224 0.055944224 0.055944224 0.001453488
## [169] 0.002057040 0.002521186 0.002913340 0.003259595 0.003573322 0.003573322
## [175] 0.003863278 0.004133709 0.004388229 0.004629466 0.005289374 0.005493522
## [181] 0.006066493 0.006247400 0.006595352 0.006763610 0.006928270 0.007247311
## [187] 0.007402599 0.007704683 0.007997093 0.008280871 0.008420011 0.008692429
## [193] 0.008958161 0.009217801 0.009471862 0.009720798 0.010084890 0.010322667
## [199] 0.010556527 0.010672254 0.010787097 0.011013895 0.011237506 0.011781323
## [205] 0.012100854 0.012415123 0.012622261 0.012725224 0.012725224 0.013033155
## [211] 0.013336898 0.013537556 0.013835016 0.014129083 0.014323689 0.014612640
## [217] 0.014804041 0.015367651 0.015554720 0.015833054 0.016109376 0.016564277
## [223] 0.017279232 0.017369006 0.017636524 0.017814509 0.017991986 0.018256838
## [229] 0.018520708 0.018696434 0.018958851 0.019220508 0.019307890 0.019740572
## [235] 0.020000411 0.020259779 0.020689581 0.021203321 0.021203321 0.021390393
## [241] 0.021681671 0.021681671 0.021681671 0.021992627 0.021992627 0.022101693
## [247] 0.022432878 0.022763598 0.023098427 0.023098427 0.023098427 0.023098427
## [253] 0.023098427 0.023098427 0.023098427 0.023366110 0.023366110 0.024038710
## [259] 0.024038710 0.024038710 0.024038710 0.024038710 0.024038710 0.024507687
## [265] 0.024507687 0.024507687 0.025232891 0.025232891 0.025232891 0.025232891
## [271] 0.025232891 0.025447809 0.025447809 0.025447809 0.025447809 0.025447809
## [277] 0.025447809 0.025447809 0.025447809 0.025973522 0.025973522 0.025973522
## [283] 0.025973522 0.026536949 0.027680495 0.028252607 0.028252607 0.028252607
## [289] 0.028252607 0.028252607 0.028252607 0.028252607 0.028252607 0.028252607
## [295] 0.028252607 0.028252607 0.030271393 0.030271393 0.030271393 0.030271393
## [301] 0.030271393 0.030271393 0.030271393 0.030271393 0.030271393 0.030271393
## [307] 0.030271393 0.030271393 0.030271393 0.030271393 0.030271393 0.030271393
## [313] 0.030271393 0.030271393 0.038074802 0.038074802 0.038074802 0.038074802
## [319] 0.038074802 0.038074802 0.038074802 0.038074802 0.038074802 0.038074802
## [325] 0.038074802 0.038074802 0.038074802 0.038074802 0.038074802 0.038074802
## 
## $strata
## get(cat)=ddC get(cat)=ddI 
##          167          163 
## 
## $type
## [1] "right"
## 
## $logse
## [1] TRUE
## 
## $conf.int
## [1] 0.95
## 
## $conf.type
## [1] "log"
## 
## $lower
##   [1] 0.9958774 0.9933576 0.9889843 0.9849864 0.9830663 0.9811838 0.9793322
##   [8] 0.9775033 0.9721390 0.9703837 0.9686420 0.9651940 0.9634857 0.9600964
##  [15] 0.9567392 0.9550713 0.9517546 0.9484612 0.9468224 0.9451885 0.9435593
##  [22] 0.9419345 0.9386974 0.9354760 0.9322687 0.9258929 0.9227226 0.9195629
##  [29] 0.9148419 0.9101415 0.9070185 0.9039035 0.8992450 0.8961483 0.8899746
##  [36] 0.8868971 0.8838256 0.8822920 0.8792288 0.8746441 0.8700708 0.8670280
##  [43] 0.8624724 0.8579268 0.8533907 0.8488636 0.8443453 0.8398353 0.8353334
##  [50] 0.8308391 0.8263523 0.8188902 0.8144220 0.8114469 0.8069895 0.8040214
##  [57] 0.8010560 0.7966129 0.7936541 0.7892206 0.7862680 0.7818437 0.7818437
##  [64] 0.7773147 0.7773147 0.7773147 0.7773147 0.7724350 0.7724350 0.7724350
##  [71] 0.7724350 0.7724350 0.7724350 0.7724350 0.7724350 0.7724350 0.7724350
##  [78] 0.7724350 0.7724350 0.7724350 0.7648528 0.7648528 0.7648528 0.7648528
##  [85] 0.7648528 0.7585500 0.7585500 0.7585500 0.7585500 0.7498162 0.7498162
##  [92] 0.7498162 0.7498162 0.7498162 0.7498162 0.7498162 0.7498162 0.7498162
##  [99] 0.7498162 0.7498162 0.7419658 0.7314043 0.7235206 0.7235206 0.7235206
## [106] 0.7181672 0.7073432 0.7073432 0.7073432 0.7073432 0.6988807 0.6988807
## [113] 0.6988807 0.6988807 0.6988807 0.6988807 0.6988807 0.6988807 0.6882843
## [120] 0.6882843 0.6773768 0.6773768 0.6773768 0.6661307 0.6661307 0.6661307
## [127] 0.6661307 0.6661307 0.6661307 0.6576584 0.6576584 0.6576584 0.6576584
## [134] 0.6396269 0.6396269 0.6396269 0.6396269 0.6396269 0.6396269 0.6396269
## [141] 0.6396269 0.6211637 0.6211637 0.6211637 0.6211637 0.5858488 0.5858488
## [148] 0.5858488 0.5858488 0.5858488 0.5858488 0.5858488 0.5858488 0.5615555
## [155] 0.5615555 0.5615555 0.5615555 0.5184695 0.5184695 0.5184695 0.5184695
## [162] 0.5184695 0.5184695 0.5184695 0.5184695 0.5184695 0.5184695 0.9957039
## [169] 0.9930782 0.9907282 0.9885213 0.9864059 0.9843558 0.9843558 0.9823515
## [176] 0.9803867 0.9784542 0.9765489 0.9709604 0.9691318 0.9637253 0.9619457
## [183] 0.9584149 0.9566624 0.9549177 0.9514495 0.9497253 0.9462946 0.9428855
## [190] 0.9394960 0.9378080 0.9344445 0.9310966 0.9277630 0.9244427 0.9211347
## [197] 0.9161942 0.9129137 0.9096431 0.9080113 0.9063818 0.9031293 0.8998851
## [204] 0.8918086 0.8869842 0.8821746 0.8789760 0.8773789 0.8773789 0.8725705
## [211] 0.8677748 0.8645844 0.8598083 0.8550432 0.8518723 0.8471244 0.8439646
## [218] 0.8345097 0.8313660 0.8266574 0.8219569 0.8141401 0.8016757 0.8001211
## [225] 0.7954619 0.7923593 0.7892597 0.7846154 0.7799772 0.7768884 0.7722601
## [232] 0.7676374 0.7660978 0.7584087 0.7538024 0.7492013 0.7415440 0.7323731
## [239] 0.7323731 0.7291818 0.7242933 0.7242933 0.7242933 0.7192301 0.7192301
## [246] 0.7174996 0.7122626 0.7070328 0.7017714 0.7017714 0.7017714 0.7017714
## [253] 0.7017714 0.7017714 0.7017714 0.6979043 0.6979043 0.6881757 0.6881757
## [260] 0.6881757 0.6881757 0.6881757 0.6881757 0.6818580 0.6818580 0.6818580
## [267] 0.6727021 0.6727021 0.6727021 0.6727021 0.6727021 0.6701996 0.6701996
## [274] 0.6701996 0.6701996 0.6701996 0.6701996 0.6701996 0.6701996 0.6645837
## [281] 0.6645837 0.6645837 0.6645837 0.6587404 0.6468970 0.6409995 0.6409995
## [288] 0.6409995 0.6409995 0.6409995 0.6409995 0.6409995 0.6409995 0.6409995
## [295] 0.6409995 0.6409995 0.6245441 0.6245441 0.6245441 0.6245441 0.6245441
## [302] 0.6245441 0.6245441 0.6245441 0.6245441 0.6245441 0.6245441 0.6245441
## [309] 0.6245441 0.6245441 0.6245441 0.6245441 0.6245441 0.6245441 0.5901601
## [316] 0.5901601 0.5901601 0.5901601 0.5901601 0.5901601 0.5901601 0.5901601
## [323] 0.5901601 0.5901601 0.5901601 0.5901601 0.5901601 0.5901601 0.5901601
## [330] 0.5901601
## 
## $upper
##   [1] 1.0000000 1.0000000 0.9998880 0.9983220 0.9974603 0.9965608 0.9956305
##   [8] 0.9946735 0.9916803 0.9906497 0.9896056 0.9874819 0.9864043 0.9842219
##  [15] 0.9820074 0.9808895 0.9786344 0.9763561 0.9752091 0.9740571 0.9729005
##  [22] 0.9717394 0.9694048 0.9670546 0.9646901 0.9599225 0.9575211 0.9551091
##  [29] 0.9514726 0.9478154 0.9453667 0.9429100 0.9392109 0.9367360 0.9317662
##  [36] 0.9292720 0.9267718 0.9255196 0.9230110 0.9192382 0.9154539 0.9129251
##  [43] 0.9091231 0.9053112 0.9014897 0.8976592 0.8938200 0.8899724 0.8861168
##  [50] 0.8822535 0.8783827 0.8719156 0.8680263 0.8654297 0.8615295 0.8589259
##  [57] 0.8563196 0.8524052 0.8497923 0.8458682 0.8432491 0.8393159 0.8393159
##  [64] 0.8352963 0.8352963 0.8352963 0.8352963 0.8310122 0.8310122 0.8310122
##  [71] 0.8310122 0.8310122 0.8310122 0.8310122 0.8310122 0.8310122 0.8310122
##  [78] 0.8310122 0.8310122 0.8310122 0.8245268 0.8245268 0.8245268 0.8245268
##  [85] 0.8245268 0.8192263 0.8192263 0.8192263 0.8192263 0.8118984 0.8118984
##  [92] 0.8118984 0.8118984 0.8118984 0.8118984 0.8118984 0.8118984 0.8118984
##  [99] 0.8118984 0.8118984 0.8055485 0.7969416 0.7904490 0.7904490 0.7904490
## [106] 0.7860328 0.7770602 0.7770602 0.7770602 0.7770602 0.7700566 0.7700566
## [113] 0.7700566 0.7700566 0.7700566 0.7700566 0.7700566 0.7700566 0.7617344
## [120] 0.7617344 0.7531293 0.7531293 0.7531293 0.7442214 0.7442214 0.7442214
## [127] 0.7442214 0.7442214 0.7442214 0.7376851 0.7376851 0.7376851 0.7376851
## [134] 0.7238121 0.7238121 0.7238121 0.7238121 0.7238121 0.7238121 0.7238121
## [141] 0.7238121 0.7107987 0.7107987 0.7107987 0.7107987 0.6860895 0.6860895
## [148] 0.6860895 0.6860895 0.6860895 0.6860895 0.6860895 0.6860895 0.6724005
## [155] 0.6724005 0.6724005 0.6724005 0.6481653 0.6481653 0.6481653 0.6481653
## [162] 0.6481653 0.6481653 0.6481653 0.6481653 0.6481653 0.6481653 1.0000000
## [169] 1.0000000 1.0000000 0.9998833 0.9990998 0.9982510 0.9982510 0.9973522
## [176] 0.9964139 0.9954433 0.9944455 0.9913247 0.9902502 0.9869474 0.9858239
## [183] 0.9835484 0.9823978 0.9812395 0.9789014 0.9777225 0.9753470 0.9729499
## [190] 0.9705332 0.9693181 0.9668754 0.9644171 0.9619445 0.9594586 0.9569603
## [197] 0.9531915 0.9506658 0.9481302 0.9468589 0.9455853 0.9430316 0.9404695
## [204] 0.9340305 0.9301457 0.9262459 0.9236383 0.9223323 0.9223323 0.9183890
## [211] 0.9144330 0.9117890 0.9078135 0.9038269 0.9011633 0.8971596 0.8944850
## [218] 0.8864365 0.8837458 0.8797027 0.8756515 0.8688822 0.8580089 0.8566462
## [225] 0.8525538 0.8498219 0.8470871 0.8429797 0.8388662 0.8361206 0.8319973
## [232] 0.8278682 0.8264907 0.8195936 0.8154483 0.8112977 0.8043690 0.7960365
## [239] 0.7960365 0.7931498 0.7887355 0.7887355 0.7887355 0.7841804 0.7841804
## [246] 0.7826279 0.7779287 0.7732223 0.7684803 0.7684803 0.7684803 0.7684803
## [253] 0.7684803 0.7684803 0.7684803 0.7650496 0.7650496 0.7563961 0.7563961
## [260] 0.7563961 0.7563961 0.7563961 0.7563961 0.7508383 0.7508383 0.7508383
## [267] 0.7428838 0.7428838 0.7428838 0.7428838 0.7428838 0.7407440 0.7407440
## [274] 0.7407440 0.7407440 0.7407440 0.7407440 0.7407440 0.7407440 0.7360585
## [281] 0.7360585 0.7360585 0.7360585 0.7312071 0.7213271 0.7163628 0.7163628
## [288] 0.7163628 0.7163628 0.7163628 0.7163628 0.7163628 0.7163628 0.7163628
## [295] 0.7163628 0.7163628 0.7036180 0.7036180 0.7036180 0.7036180 0.7036180
## [302] 0.7036180 0.7036180 0.7036180 0.7036180 0.7036180 0.7036180 0.7036180
## [309] 0.7036180 0.7036180 0.7036180 0.7036180 0.7036180 0.7036180 0.6862347
## [316] 0.6862347 0.6862347 0.6862347 0.6862347 0.6862347 0.6862347 0.6862347
## [323] 0.6862347 0.6862347 0.6862347 0.6862347 0.6862347 0.6862347 0.6862347
## [330] 0.6862347
## 
## $t0
## [1] 0
## 
## $call
## survfit(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survfit"

## 
## ++++++++++++++++++++++++++ sex ++++++++++++++++++++++++++
## $n
## [1]  117 1288
## 
## $time
##   [1]  0.47  0.90  1.13  1.43  1.90  2.73  3.30  3.40  3.83  4.53  4.57  8.00
##  [13]  9.57 11.07 11.60 12.20 12.23 12.27 12.30 12.43 12.47 12.53 12.57 12.73
##  [25] 13.20 13.40 13.47 13.50 13.90 13.93 14.40 14.43 14.90 15.07 15.53 16.27
##  [37] 16.93 17.20 17.37 17.87 18.53 18.87 19.27  0.77  1.03  1.07  1.30  1.43
##  [49]  1.63  1.70  1.83  2.00  2.03  2.13  2.17  2.40  2.47  2.57  2.60  2.70
##  [61]  3.00  3.13  3.20  3.30  3.37  3.43  3.57  3.63  3.90  3.97  4.10  4.20
##  [73]  4.33  4.53  4.60  4.67  4.93  4.97  5.03  5.07  5.10  5.23  5.37  5.43
##  [85]  5.53  5.57  5.90  6.00  6.07  6.13  6.30  6.60  6.63  6.87  6.90  7.03
##  [97]  7.10  7.17  7.30  7.40  7.57  7.67  7.70  7.73  7.83  7.93  7.97  8.07
## [109]  8.13  8.17  8.30  8.33  8.43  8.47  8.73  8.80  9.07  9.33  9.37  9.57
## [121]  9.60  9.63  9.67  9.73  9.77  9.80  9.93 10.03 10.07 10.23 10.30 10.33
## [133] 10.40 10.57 10.60 10.63 10.70 10.80 10.87 10.93 11.00 11.03 11.07 11.13
## [145] 11.17 11.20 11.30 11.47 11.50 11.57 11.63 11.67 11.90 11.93 12.07 12.20
## [157] 12.23 12.27 12.30 12.33 12.37 12.43 12.47 12.50 12.53 12.63 12.67 12.70
## [169] 12.73 12.77 12.90 12.93 12.97 13.00 13.03 13.10 13.13 13.20 13.23 13.27
## [181] 13.30 13.37 13.43 13.47 13.50 13.60 13.70 13.73 13.83 13.87 13.90 13.93
## [193] 14.07 14.10 14.13 14.17 14.20 14.30 14.33 14.40 14.43 14.57 14.60 14.63
## [205] 14.70 14.83 14.87 15.03 15.07 15.10 15.13 15.17 15.27 15.33 15.37 15.47
## [217] 15.50 15.57 15.60 15.70 15.77 15.80 15.90 15.93 15.97 16.00 16.03 16.17
## [229] 16.20 16.23 16.30 16.40 16.43 16.47 16.50 16.63 16.67 16.70 16.73 16.87
## [241] 16.93 16.97 17.00 17.03 17.10 17.17 17.20 17.23 17.27 17.33 17.37 17.40
## [253] 17.43 17.57 17.63 17.67 17.70 17.80 17.83 17.87 17.93 18.03 18.07 18.10
## [265] 18.13 18.17 18.33 18.37 18.40 18.50 18.57 18.60 18.63 18.77 18.80 18.97
## [277] 19.00 19.03 19.07 19.20 19.53 19.57 19.70 19.77 19.80 19.93 20.23 20.27
## [289] 20.40 20.50 20.63 20.67 20.87 21.13 21.40
## 
## $n.risk
##   [1]  117  116  115  114  113  112  111  110  108  107  106  105  103  100   98
##  [16]   95   93   91   87   85   81   79   78   75   71   68   64   60   56   48
##  [31]   44   40   37   33   31   27   24   20   17   16   14   11    9 1288 1287
##  [46] 1286 1284 1283 1282 1281 1280 1279 1277 1276 1275 1273 1272 1269 1268 1265
##  [61] 1264 1263 1260 1257 1255 1253 1252 1250 1249 1247 1246 1244 1243 1241 1240
##  [76] 1238 1237 1236 1234 1233 1231 1229 1227 1225 1223 1221 1217 1215 1213 1211
##  [91] 1208 1206 1204 1203 1202 1200 1198 1195 1187 1184 1181 1179 1177 1175 1172
## [106] 1171 1166 1162 1159 1156 1154 1151 1149 1148 1143 1140 1137 1135 1132 1128
## [121] 1125 1122 1119 1117 1114 1111 1108 1103 1100 1097 1089 1085 1082 1079 1076
## [136] 1073 1071 1066 1063 1061 1058 1056 1053 1050 1048 1046 1043 1037 1036 1031
## [151] 1029 1026 1023 1021 1016 1013  992  958  940  927  915  912  904  889  882
## [166]  866  863  853  831  827  819  816  809  805  797  788  784  780  763  755
## [181]  752  747  738  734  731  720  712  708  700  698  687  678  666  656  652
## [196]  644  636  628  624  610  598  597  593  585  575  571  568  561  549  547
## [211]  539  535  531  527  521  517  513  509  495  487  484  482  479  475  468
## [226]  451  448  429  422  416  401  394  391  387  375  371  364  360  356  352
## [241]  348  344  334  330  328  324  320  313  310  306  302  291  285  281  277
## [256]  273  264  256  245  234  230  218  209  204  199  181  168  163  145  137
## [271]  134  124  119  117  114  109  104  100   95   92   87   82   73   68   64
## [286]   51   48   44   32   27   22   20   15   10    4
## 
## $n.event
##   [1] 1 1 1 1 1 1 1 2 1 1 1 2 3 2 3 0 0 0 0 0 0 1 0 0 0 0 0 0 4 0 0 0 0 0 0 3 0
##  [38] 0 0 0 3 0 0 1 1 2 1 1 1 1 0 2 1 1 1 1 3 1 3 1 1 3 3 2 2 1 2 1 2 1 2 1 2 1
##  [75] 2 1 1 2 1 2 2 2 2 2 2 4 2 2 2 3 2 2 1 1 2 2 3 8 3 3 2 2 2 3 1 2 4 3 3 2 3
## [112] 2 1 5 3 3 2 3 4 3 3 3 2 3 3 3 5 3 3 8 4 3 3 3 3 2 5 3 2 3 2 3 3 2 2 3 6 1
## [149] 5 2 3 3 2 5 3 6 3 2 3 0 3 0 3 0 0 3 3 3 0 0 0 0 0 0 0 4 0 2 0 0 5 0 0 0 0
## [186] 3 0 0 0 3 0 0 0 0 4 0 0 0 0 0 1 0 0 3 4 0 3 0 2 2 0 4 0 2 0 4 0 2 0 3 0 0
## [223] 0 0 0 0 0 0 0 0 0 3 0 0 0 7 0 0 0 0 0 0 0 2 0 0 0 0 4 0 0 0 0 0 0 0 0 3 0
## [260] 0 0 0 5 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 
## $n.censor
##   [1]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  2  2  4  2  4  2  0  3  4  3
##  [26]  4  4  4  4  4  4  3  4  2  4  0  4  3  1  2  0  2  9  0  0  0  0  0  0  0
##  [51]  1  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [76]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [101]  0  0  0  0  0  3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [126]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [151]  0  0  0  0  0 15 31 16 10 12  0  8 12  7 16  0  7 19  4  8  3  7  4  8  9
## [176]  0  4 15  8  3  0  9  4  3 11  5  4  8  2  8  9 12 10  4  4  8  8  4 14 12
## [201]  0  4  8  7  0  3  4 12  0  6  4  0  4  4  4  0  4 12  8  0  2  3  4  7 17
## [226]  3 19  7  6 15  7  0  4 12  4  0  4  4  4  4  4 10  4  0  4  4  7  3  0  4
## [251] 11  6  4  4  4  9  8  8 11  4 12  9  0  5 18 13  5 18  8  3 10  5  0  3  5
## [276]  5  4  5  0  5  5  9  5  4 13  3  4 12  5  5  2  5  5  6  4
## 
## $surv
##   [1] 0.9914530 0.9829060 0.9743590 0.9658120 0.9572650 0.9487179 0.9401709
##   [8] 0.9230769 0.9145299 0.9059829 0.8974359 0.8803419 0.8547009 0.8376068
##  [15] 0.8119658 0.8119658 0.8119658 0.8119658 0.8119658 0.8119658 0.8119658
##  [22] 0.8016878 0.8016878 0.8016878 0.8016878 0.8016878 0.8016878 0.8016878
##  [29] 0.7444244 0.7444244 0.7444244 0.7444244 0.7444244 0.7444244 0.7444244
##  [36] 0.6617105 0.6617105 0.6617105 0.6617105 0.6617105 0.5199154 0.5199154
##  [43] 0.5199154 0.9992236 0.9984472 0.9968944 0.9961180 0.9953416 0.9945652
##  [50] 0.9937888 0.9937888 0.9922348 0.9914578 0.9906808 0.9899038 0.9891262
##  [57] 0.9867933 0.9860157 0.9836829 0.9829053 0.9821276 0.9797948 0.9774620
##  [64] 0.9759067 0.9743515 0.9735739 0.9720187 0.9712410 0.9696858 0.9689082
##  [71] 0.9673530 0.9665753 0.9650201 0.9642425 0.9626873 0.9619097 0.9611320
##  [78] 0.9595768 0.9587992 0.9572440 0.9556887 0.9541335 0.9525783 0.9510231
##  [85] 0.9494678 0.9463574 0.9448021 0.9432469 0.9416917 0.9393588 0.9378036
##  [92] 0.9362484 0.9354708 0.9346931 0.9331379 0.9315827 0.9292498 0.9230289
##  [99] 0.9206961 0.9183632 0.9168080 0.9152528 0.9136975 0.9113647 0.9105871
## [106] 0.9090318 0.9059134 0.9035745 0.9012357 0.8996765 0.8973376 0.8957784
## [113] 0.8949988 0.8911007 0.8887618 0.8864230 0.8848638 0.8825249 0.8794065
## [120] 0.8770676 0.8747288 0.8723899 0.8708307 0.8684918 0.8661530 0.8638141
## [127] 0.8599161 0.8575772 0.8552384 0.8490014 0.8458830 0.8435441 0.8412053
## [134] 0.8388664 0.8365276 0.8349684 0.8310703 0.8287314 0.8271722 0.8248334
## [141] 0.8232741 0.8209353 0.8185964 0.8170372 0.8154780 0.8131391 0.8084614
## [148] 0.8076818 0.8037837 0.8022245 0.7998857 0.7975468 0.7959876 0.7920895
## [155] 0.7897507 0.7850730 0.7826987 0.7810647 0.7785720 0.7785720 0.7760193
## [162] 0.7760193 0.7734440 0.7734440 0.7734440 0.7707646 0.7680852 0.7653839
## [169] 0.7653839 0.7653839 0.7653839 0.7653839 0.7653839 0.7653839 0.7653839
## [176] 0.7614987 0.7614987 0.7595461 0.7595461 0.7595461 0.7544960 0.7544960
## [183] 0.7544960 0.7544960 0.7544960 0.7513522 0.7513522 0.7513522 0.7513522
## [190] 0.7481229 0.7481229 0.7481229 0.7481229 0.7481229 0.7435332 0.7435332
## [197] 0.7435332 0.7435332 0.7435332 0.7435332 0.7422898 0.7422898 0.7422898
## [204] 0.7384832 0.7333459 0.7333459 0.7294726 0.7294726 0.7268152 0.7241577
## [211] 0.7241577 0.7187435 0.7187435 0.7160158 0.7160158 0.7104760 0.7104760
## [218] 0.7076844 0.7076844 0.7033249 0.7033249 0.7033249 0.7033249 0.7033249
## [225] 0.7033249 0.7033249 0.7033249 0.7033249 0.7033249 0.7033249 0.7033249
## [232] 0.6979696 0.6979696 0.6979696 0.6979696 0.6848004 0.6848004 0.6848004
## [239] 0.6848004 0.6848004 0.6848004 0.6848004 0.6848004 0.6806501 0.6806501
## [246] 0.6806501 0.6806501 0.6806501 0.6718675 0.6718675 0.6718675 0.6718675
## [253] 0.6718675 0.6718675 0.6718675 0.6718675 0.6718675 0.6639941 0.6639941
## [260] 0.6639941 0.6639941 0.6639941 0.6481090 0.6481090 0.6481090 0.6481090
## [267] 0.6481090 0.6481090 0.6481090 0.6481090 0.6481090 0.6481090 0.6372164
## [274] 0.6372164 0.6372164 0.6372164 0.6372164 0.6372164 0.6170938 0.6170938
## [281] 0.6170938 0.6170938 0.6170938 0.6170938 0.6170938 0.6170938 0.6170938
## [288] 0.6170938 0.6170938 0.6170938 0.6170938 0.6170938 0.6170938 0.6170938
## [295] 0.6170938
## 
## $std.err
##   [1] 0.0085837700 0.0121919493 0.0149973757 0.0173939350 0.0195336346
##   [6] 0.0214941960 0.0233216754 0.0266880256 0.0282627997 0.0297817682
##  [11] 0.0312538154 0.0340841505 0.0381181250 0.0407071626 0.0444894060
##  [16] 0.0444894060 0.0444894060 0.0444894060 0.0444894060 0.0444894060
##  [21] 0.0444894060 0.0462773402 0.0462773402 0.0462773402 0.0462773402
##  [26] 0.0462773402 0.0462773402 0.0462773402 0.0592892789 0.0592892789
##  [31] 0.0592892789 0.0592892789 0.0592892789 0.0592892789 0.0592892789
##  [36] 0.0902488128 0.0902488128 0.0902488128 0.0902488128 0.0902488128
##  [41] 0.1662088075 0.1662088075 0.1662088075 0.0007766991 0.0010988454
##  [46] 0.0015552118 0.0017394572 0.0019062229 0.0020597595 0.0022028356
##  [51] 0.0022028356 0.0024651596 0.0025866417 0.0027028469 0.0028144293
##  [56] 0.0029220848 0.0032244569 0.0033194263 0.0035901103 0.0036761798
##  [61] 0.0037604115 0.0040032301 0.0042332028 0.0043803889 0.0045232350
##  [66] 0.0045931582 0.0047302281 0.0047974545 0.0049294702 0.0049943244
##  [71] 0.0051218726 0.0051846202 0.0053081852 0.0053690475 0.0054890345
##  [76] 0.0055481975 0.0056068303 0.0057225719 0.0057797116 0.0058926007
##  [81] 0.0060037245 0.0061131811 0.0062210601 0.0063274439 0.0064324083
##  [86] 0.0066383541 0.0067394603 0.0068393981 0.0069382195 0.0070844638
##  [91] 0.0071807001 0.0072759770 0.0073232679 0.0073703333 0.0074638054
##  [96] 0.0075564276 0.0076938379 0.0080520209 0.0081834988 0.0083135497
## [101] 0.0083994927 0.0084848530 0.0085696492 0.0086958253 0.0087376211
## [106] 0.0088208305 0.0089866187 0.0091097139 0.0092317940 0.0093126389
## [111] 0.0094331251 0.0095129457 0.0095527094 0.0097501157 0.0098674769
## [116] 0.0099840670 0.0100613809 0.0101767551 0.0103295179 0.0104433235
## [121] 0.0105565011 0.0106690753 0.0107438013 0.0108554220 0.0109665002
## [126] 0.0110770571 0.0112602145 0.0113694779 0.0114782902 0.0117663828
## [131] 0.0119093704 0.0120161781 0.0121226308 0.0122287427 0.0123345274
## [136] 0.0124048754 0.0125801598 0.0126849474 0.0127546535 0.0128589930
## [141] 0.0129284111 0.0130323342 0.0131360219 0.0132050214 0.0132739241
## [146] 0.0133771031 0.0135828669 0.0136170879 0.0137879013 0.0138560967
## [151] 0.0139582587 0.0140602711 0.0141282004 0.0142977651 0.0143993385
## [156] 0.0146021497 0.0147064818 0.0147805404 0.0148953163 0.0148953163
## [161] 0.0150155087 0.0150155087 0.0151376591 0.0151376591 0.0151376591
## [166] 0.0152696714 0.0154014613 0.0155352070 0.0155352070 0.0155352070
## [171] 0.0155352070 0.0155352070 0.0155352070 0.0155352070 0.0155352070
## [176] 0.0157422148 0.0157422148 0.0158465482 0.0158465482 0.0158465482
## [181] 0.0161249478 0.0161249478 0.0161249478 0.0161249478 0.0161249478
## [186] 0.0163041464 0.0163041464 0.0163041464 0.0163041464 0.0164927061
## [191] 0.0164927061 0.0164927061 0.0164927061 0.0164927061 0.0167772733
## [196] 0.0167772733 0.0167772733 0.0167772733 0.0167772733 0.0167772733
## [201] 0.0168605449 0.0168605449 0.0168605449 0.0171198517 0.0174720455
## [206] 0.0174720455 0.0177375448 0.0177375448 0.0179242974 0.0181104737
## [211] 0.0181104737 0.0184951223 0.0184951223 0.0186895224 0.0186895224
## [216] 0.0190887404 0.0190887404 0.0192906728 0.0192906728 0.0196177896
## [221] 0.0196177896 0.0196177896 0.0196177896 0.0196177896 0.0196177896
## [226] 0.0196177896 0.0196177896 0.0196177896 0.0196177896 0.0196177896
## [231] 0.0196177896 0.0201079924 0.0201079924 0.0201079924 0.0201079924
## [236] 0.0213580504 0.0213580504 0.0213580504 0.0213580504 0.0213580504
## [241] 0.0213580504 0.0213580504 0.0213580504 0.0217863208 0.0217863208
## [246] 0.0217863208 0.0217863208 0.0217863208 0.0227334815 0.0227334815
## [251] 0.0227334815 0.0227334815 0.0227334815 0.0227334815 0.0227334815
## [256] 0.0227334815 0.0227334815 0.0237303677 0.0237303677 0.0237303677
## [261] 0.0237303677 0.0237303677 0.0260845191 0.0260845191 0.0260845191
## [266] 0.0260845191 0.0260845191 0.0260845191 0.0260845191 0.0260845191
## [271] 0.0260845191 0.0260845191 0.0287062596 0.0287062596 0.0287062596
## [276] 0.0287062596 0.0287062596 0.0287062596 0.0341657543 0.0341657543
## [281] 0.0341657543 0.0341657543 0.0341657543 0.0341657543 0.0341657543
## [286] 0.0341657543 0.0341657543 0.0341657543 0.0341657543 0.0341657543
## [291] 0.0341657543 0.0341657543 0.0341657543 0.0341657543 0.0341657543
## 
## $cumhaz
##   [1] 0.0085470085 0.0171676982 0.0258633504 0.0346352802 0.0434848377
##   [6] 0.0524134092 0.0614224182 0.0796042363 0.0888634956 0.0982092900
##  [11] 0.1076432523 0.1266908713 0.1558170849 0.1758170849 0.2064293298
##  [16] 0.2064293298 0.2064293298 0.2064293298 0.2064293298 0.2064293298
##  [21] 0.2064293298 0.2190875576 0.2190875576 0.2190875576 0.2190875576
##  [26] 0.2190875576 0.2190875576 0.2190875576 0.2905161291 0.2905161291
##  [31] 0.2905161291 0.2905161291 0.2905161291 0.2905161291 0.2905161291
##  [36] 0.4016272402 0.4016272402 0.4016272402 0.4016272402 0.4016272402
##  [41] 0.6159129545 0.6159129545 0.6159129545 0.0007763975 0.0015533983
##  [46] 0.0031086082 0.0038874244 0.0046668477 0.0054468789 0.0062275190
##  [51] 0.0062275190 0.0077912407 0.0085743260 0.0093580251 0.0101423388
##  [56] 0.0109278848 0.0132863753 0.0140743974 0.0164403280 0.0172308418
##  [61] 0.0180219811 0.0203972780 0.0227782303 0.0243693202 0.0259629457
##  [66] 0.0267610303 0.0283584744 0.0291584744 0.0307597555 0.0315616801
##  [71] 0.0331668165 0.0339706750 0.0355796855 0.0363854873 0.0379983905
##  [76] 0.0388061449 0.0396145524 0.0412326753 0.0420430481 0.0436651081
##  [81] 0.0452898035 0.0469171428 0.0485471347 0.0501797877 0.0518151107
##  [86] 0.0550911140 0.0567344993 0.0583805899 0.0600293945 0.0625066860
##  [91] 0.0641623151 0.0658206899 0.0666512547 0.0674825099 0.0691464034
##  [96] 0.0708130701 0.0733172437 0.0800118044 0.0825391843 0.0850729681
## [101] 0.0867664482 0.0884628010 0.0901620364 0.0927152279 0.0935684702
## [106] 0.0952764121 0.0987069439 0.1012886995 0.1038771378 0.1056072416
## [111] 0.1082068949 0.1099445144 0.1108148364 0.1151702371 0.1177949090
## [116] 0.1204264880 0.1221855029 0.1248286747 0.1283622437 0.1310218181
## [121] 0.1336884848 0.1363622816 0.1381495917 0.1408353571 0.1435283553
## [126] 0.1462286254 0.1507412607 0.1534611157 0.1561883884 0.1634810046
## [131] 0.1671540992 0.1699190762 0.1726917194 0.1754720716 0.1782601757
## [136] 0.1801241086 0.1847926427 0.1876069016 0.1894883691 0.1923158903
## [141] 0.1942062495 0.1970471586 0.1998961614 0.2018009233 0.2037093203
## [146] 0.2065773891 0.2123300257 0.2132943459 0.2181206007 0.2200604649
## [151] 0.2229759168 0.2258998934 0.2278549277 0.2327520873 0.2357048432
## [156] 0.2416278442 0.2446520377 0.2467397204 0.2499312098 0.2499312098
## [161] 0.2532098983 0.2532098983 0.2565284824 0.2565284824 0.2565284824
## [166] 0.2599926856 0.2634689313 0.2669859301 0.2669859301 0.2669859301
## [171] 0.2669859301 0.2669859301 0.2669859301 0.2669859301 0.2669859301
## [176] 0.2720620722 0.2720620722 0.2746261748 0.2746261748 0.2746261748
## [181] 0.2812751110 0.2812751110 0.2812751110 0.2812751110 0.2812751110
## [186] 0.2854417776 0.2854417776 0.2854417776 0.2854417776 0.2897397719
## [191] 0.2897397719 0.2897397719 0.2897397719 0.2897397719 0.2958747412
## [196] 0.2958747412 0.2958747412 0.2958747412 0.2958747412 0.2958747412
## [201] 0.2975469820 0.2975469820 0.2975469820 0.3026751871 0.3096317089
## [206] 0.3096317089 0.3149133990 0.3149133990 0.3185563863 0.3222126934
## [211] 0.3222126934 0.3296893289 0.3296893289 0.3334843953 0.3334843953
## [216] 0.3412213392 0.3412213392 0.3451506123 0.3451506123 0.3513107766
## [221] 0.3513107766 0.3513107766 0.3513107766 0.3513107766 0.3513107766
## [226] 0.3513107766 0.3513107766 0.3513107766 0.3513107766 0.3513107766
## [231] 0.3513107766 0.3589249898 0.3589249898 0.3589249898 0.3589249898
## [236] 0.3777929143 0.3777929143 0.3777929143 0.3777929143 0.3777929143
## [241] 0.3777929143 0.3777929143 0.3777929143 0.3838535204 0.3838535204
## [246] 0.3838535204 0.3838535204 0.3838535204 0.3967567462 0.3967567462
## [251] 0.3967567462 0.3967567462 0.3967567462 0.3967567462 0.3967567462
## [256] 0.3967567462 0.3967567462 0.4084754962 0.4084754962 0.4084754962
## [261] 0.4084754962 0.4084754962 0.4323989412 0.4323989412 0.4323989412
## [266] 0.4323989412 0.4323989412 0.4323989412 0.4323989412 0.4323989412
## [271] 0.4323989412 0.4323989412 0.4492056639 0.4492056639 0.4492056639
## [276] 0.4492056639 0.4492056639 0.4492056639 0.4807846112 0.4807846112
## [281] 0.4807846112 0.4807846112 0.4807846112 0.4807846112 0.4807846112
## [286] 0.4807846112 0.4807846112 0.4807846112 0.4807846112 0.4807846112
## [291] 0.4807846112 0.4807846112 0.4807846112 0.4807846112 0.4807846112
## 
## $std.chaz
##   [1] 0.0085470085 0.0121395076 0.0149325822 0.0173184516 0.0194484815
##   [6] 0.0214000659 0.0232190668 0.0265408048 0.0281095749 0.0296224927
##  [11] 0.0310884499 0.0338806378 0.0378242830 0.0403816343 0.0440799981
##  [16] 0.0440799981 0.0440799981 0.0440799981 0.0440799981 0.0440799981
##  [21] 0.0440799981 0.0458614976 0.0458614976 0.0458614976 0.0458614976
##  [26] 0.0458614976 0.0458614976 0.0458614976 0.0581273358 0.0581273358
##  [31] 0.0581273358 0.0581273358 0.0581273358 0.0581273358 0.0581273358
##  [36] 0.0865679704 0.0865679704 0.0865679704 0.0865679704 0.0865679704
##  [41] 0.1509971389 0.1509971389 0.1509971389 0.0007763975 0.0010984185
##  [46] 0.0015543044 0.0017385100 0.0019052343 0.0020587293 0.0022017641
##  [51] 0.0022017641 0.0024638137 0.0025852661 0.0027014413 0.0028129936
##  [56] 0.0029206190 0.0032224485 0.0033174016 0.0035876217 0.0036736823
##  [61] 0.0037579040 0.0040003151 0.0042299132 0.0043769795 0.0045197091
##  [66] 0.0045896306 0.0047265869 0.0047938109 0.0049257156 0.0049905668
##  [71] 0.0051180063 0.0051807506 0.0053042091 0.0053650676 0.0054849502
##  [76] 0.0055441092 0.0056027376 0.0057183765 0.0057755116 0.0058882997
##  [81] 0.0059993242 0.0061086830 0.0062164656 0.0063227543 0.0064276250
##  [86] 0.0066330545 0.0067340753 0.0068339284 0.0069326658 0.0070786660
##  [91] 0.0071748217 0.0072700186 0.0073173088 0.0073643733 0.0074577654
##  [96] 0.0075503081 0.0076874865 0.0080436056 0.0081748888 0.0083047473
## [101] 0.0083906356 0.0084759407 0.0085606817 0.0086866680 0.0087284720
## [106] 0.0088116262 0.0089770203 0.0090999293 0.0092218247 0.0093026169
## [111] 0.0094229196 0.0095026877 0.0095424596 0.0097392216 0.0098564060
## [116] 0.0099728201 0.0100500850 0.0101652838 0.0103176800 0.0104313134
## [121] 0.0105443193 0.0106567224 0.0107314012 0.0108428510 0.0109537587
## [126] 0.0110641455 0.0112466925 0.0113557898 0.0114644364 0.0117507907
## [131] 0.0118934431 0.0120000981 0.0121063980 0.0122123568 0.0123179882
## [136] 0.0123882991 0.0125630011 0.0126676365 0.0127373064 0.0128414927
## [141] 0.0129108738 0.0130146424 0.0131181753 0.0131871370 0.0132560013
## [146] 0.0133590236 0.0135638852 0.0135981210 0.0137683493 0.0138365089
## [151] 0.0139385174 0.0140403756 0.0141082680 0.0142772427 0.0143786618
## [156] 0.0145805660 0.0146847366 0.0147587499 0.0148733284 0.0148733284
## [161] 0.0149933040 0.0149933040 0.0151152296 0.0151152296 0.0151152296
## [166] 0.0152469800 0.0153785076 0.0155119821 0.0155119821 0.0155119821
## [171] 0.0155119821 0.0155119821 0.0155119821 0.0155119821 0.0155119821
## [176] 0.0157182503 0.0157182503 0.0158224746 0.0158224746 0.0158224746
## [181] 0.0160994526 0.0160994526 0.0160994526 0.0160994526 0.0160994526
## [186] 0.0162781882 0.0162781882 0.0162781882 0.0162781882 0.0164662381
## [191] 0.0164662381 0.0164662381 0.0164662381 0.0164662381 0.0167495211
## [196] 0.0167495211 0.0167495211 0.0167495211 0.0167495211 0.0167495211
## [201] 0.0168327908 0.0168327908 0.0168327908 0.0170911969 0.0174415398
## [206] 0.0174415398 0.0177061023 0.0177061023 0.0178925051 0.0180783303
## [211] 0.0180783303 0.0184607976 0.0184607976 0.0186548201 0.0186548201
## [216] 0.0190517030 0.0190517030 0.0192532330 0.0192532330 0.0195789731
## [221] 0.0195789731 0.0195789731 0.0195789731 0.0195789731 0.0195789731
## [226] 0.0195789731 0.0195789731 0.0195789731 0.0195789731 0.0195789731
## [231] 0.0195789731 0.0200664298 0.0200664298 0.0200664298 0.0200664298
## [236] 0.0212959748 0.0212959748 0.0212959748 0.0212959748 0.0212959748
## [241] 0.0212959748 0.0212959748 0.0212959748 0.0217228915 0.0217228915
## [246] 0.0217228915 0.0217228915 0.0217228915 0.0226607000 0.0226607000
## [251] 0.0226607000 0.0226607000 0.0226607000 0.0226607000 0.0226607000
## [256] 0.0226607000 0.0226607000 0.0236491795 0.0236491795 0.0236491795
## [261] 0.0236491795 0.0236491795 0.0259566935 0.0259566935 0.0259566935
## [266] 0.0259566935 0.0259566935 0.0259566935 0.0259566935 0.0259566935
## [271] 0.0259566935 0.0259566935 0.0285479053 0.0285479053 0.0285479053
## [276] 0.0285479053 0.0285479053 0.0285479053 0.0338731881 0.0338731881
## [281] 0.0338731881 0.0338731881 0.0338731881 0.0338731881 0.0338731881
## [286] 0.0338731881 0.0338731881 0.0338731881 0.0338731881 0.0338731881
## [291] 0.0338731881 0.0338731881 0.0338731881 0.0338731881 0.0338731881
## 
## $strata
## get(cat)=female   get(cat)=male 
##              43             252 
## 
## $type
## [1] "right"
## 
## $logse
## [1] TRUE
## 
## $conf.int
## [1] 0.95
## 
## $conf.type
## [1] "log"
## 
## $lower
##   [1] 0.9749124 0.9596971 0.9461352 0.9334409 0.9213085 0.9095807 0.8981634
##   [8] 0.8760341 0.8652479 0.8546134 0.8441121 0.8234531 0.7931730 0.7733752
##  [15] 0.7441634 0.7441634 0.7441634 0.7441634 0.7441634 0.7441634 0.7441634
##  [22] 0.7321733 0.7321733 0.7321733 0.7321733 0.7321733 0.7321733 0.7321733
##  [29] 0.6627557 0.6627557 0.6627557 0.6627557 0.6627557 0.6627557 0.6627557
##  [36] 0.5544318 0.5544318 0.5544318 0.5544318 0.5544318 0.3753665 0.3753665
##  [43] 0.3753665 0.9977036 0.9962992 0.9938603 0.9927278 0.9916298 0.9905582
##  [50] 0.9895074 0.9895074 0.9874523 0.9864441 0.9854466 0.9844583 0.9834775
##  [57] 0.9805766 0.9796216 0.9767855 0.9758487 0.9749157 0.9721372 0.9693856
##  [64] 0.9675640 0.9657517 0.9648487 0.9630486 0.9621514 0.9603622 0.9594701
##  [71] 0.9576906 0.9568031 0.9550322 0.9541488 0.9523859 0.9515063 0.9506278
##  [78] 0.9488743 0.9479992 0.9462521 0.9445090 0.9427697 0.9410340 0.9393017
##  [85] 0.9375727 0.9341241 0.9324042 0.9306871 0.9289726 0.9264057 0.9246975
##  [92] 0.9229916 0.9221395 0.9212880 0.9195866 0.9178873 0.9153422 0.9085763
##  [99] 0.9060465 0.9035204 0.9018384 0.9001580 0.8984790 0.8959635 0.8951257
## [106] 0.8934511 0.8900968 0.8875846 0.8850754 0.8834041 0.8808995 0.8792313
## [113] 0.8783976 0.8742335 0.8717384 0.8692457 0.8675852 0.8650964 0.8617815
## [120] 0.8592978 0.8568162 0.8543368 0.8526849 0.8502088 0.8477346 0.8452623
## [127] 0.8411459 0.8386785 0.8362128 0.8296461 0.8263671 0.8239097 0.8214539
## [134] 0.8189996 0.8165468 0.8149125 0.8108294 0.8083815 0.8067503 0.8043047
## [141] 0.8026751 0.8002317 0.7977897 0.7961625 0.7945358 0.7920968 0.7872226
## [148] 0.7864107 0.7823533 0.7807313 0.7782993 0.7758684 0.7742484 0.7702008
## [155] 0.7677737 0.7629229 0.7604601 0.7587624 0.7561707 0.7561707 0.7535139
## [162] 0.7535139 0.7508335 0.7508335 0.7508335 0.7480389 0.7452460 0.7424304
## [169] 0.7424304 0.7424304 0.7424304 0.7424304 0.7424304 0.7424304 0.7424304
## [176] 0.7383620 0.7383620 0.7363182 0.7363182 0.7363182 0.7310235 0.7310235
## [183] 0.7310235 0.7310235 0.7310235 0.7277219 0.7277219 0.7277219 0.7277219
## [190] 0.7243264 0.7243264 0.7243264 0.7243264 0.7243264 0.7194813 0.7194813
## [197] 0.7194813 0.7194813 0.7194813 0.7194813 0.7181610 0.7181610 0.7181610
## [204] 0.7141151 0.7086580 0.7086580 0.7045483 0.7045483 0.7017248 0.6989040
## [211] 0.6989040 0.6931557 0.6931557 0.6902621 0.6902621 0.6843859 0.6843859
## [218] 0.6814270 0.6814270 0.6767952 0.6767952 0.6767952 0.6767952 0.6767952
## [225] 0.6767952 0.6767952 0.6767952 0.6767952 0.6767952 0.6767952 0.6767952
## [232] 0.6709970 0.6709970 0.6709970 0.6709970 0.6567257 0.6567257 0.6567257
## [239] 0.6567257 0.6567257 0.6567257 0.6567257 0.6567257 0.6521978 0.6521978
## [246] 0.6521978 0.6521978 0.6521978 0.6425884 0.6425884 0.6425884 0.6425884
## [253] 0.6425884 0.6425884 0.6425884 0.6425884 0.6425884 0.6338184 0.6338184
## [260] 0.6338184 0.6338184 0.6338184 0.6158074 0.6158074 0.6158074 0.6158074
## [267] 0.6158074 0.6158074 0.6158074 0.6158074 0.6158074 0.6158074 0.6023545
## [274] 0.6023545 0.6023545 0.6023545 0.6023545 0.6023545 0.5771242 0.5771242
## [281] 0.5771242 0.5771242 0.5771242 0.5771242 0.5771242 0.5771242 0.5771242
## [288] 0.5771242 0.5771242 0.5771242 0.5771242 0.5771242 0.5771242 0.5771242
## [295] 0.5771242
## 
## $upper
##   [1] 1.0000000 1.0000000 1.0000000 0.9993056 0.9946247 0.9895392 0.9841431
##   [8] 0.9726459 0.9666188 0.9604401 0.9541282 0.9411608 0.9210015 0.9071732
##  [15] 0.8859459 0.8859459 0.8859459 0.8859459 0.8859459 0.8859459 0.8859459
##  [22] 0.8778021 0.8778021 0.8778021 0.8778021 0.8778021 0.8778021 0.8778021
##  [29] 0.8361567 0.8361567 0.8361567 0.8361567 0.8361567 0.8361567 0.8361567
##  [36] 0.7897470 0.7897470 0.7897470 0.7897470 0.7897470 0.7201283 0.7201283
##  [43] 0.7201283 1.0000000 1.0000000 0.9999377 0.9995198 0.9990673 0.9985884
##  [50] 0.9980888 0.9980888 0.9970405 0.9964970 0.9959428 0.9953794 0.9948073
##  [57] 0.9930494 0.9924516 0.9906290 0.9900128 0.9893929 0.9875127 0.9856056
##  [64] 0.9843214 0.9830279 0.9823780 0.9810722 0.9804165 0.9790999 0.9784391
##  [71] 0.9771128 0.9764474 0.9751125 0.9744429 0.9731001 0.9724268 0.9717524
##  [78] 0.9704000 0.9697223 0.9683635 0.9670008 0.9656343 0.9642642 0.9628907
##  [85] 0.9615138 0.9587508 0.9573649 0.9559762 0.9545849 0.9524931 0.9510955
##  [92] 0.9496955 0.9489947 0.9482933 0.9468889 0.9454824 0.9433688 0.9377114
##  [99] 0.9355825 0.9334499 0.9320261 0.9306007 0.9291738 0.9270307 0.9263156
## [106] 0.9248843 0.9220110 0.9198525 0.9176911 0.9162485 0.9140824 0.9126369
## [113] 0.9119136 0.9082933 0.9061177 0.9039397 0.9024864 0.9003045 0.8973919
## [120] 0.8952049 0.8930157 0.8908245 0.8893626 0.8871680 0.8849715 0.8827732
## [127] 0.8791050 0.8769018 0.8746968 0.8688084 0.8658598 0.8636465 0.8614316
## [134] 0.8592152 0.8569973 0.8555178 0.8518164 0.8495937 0.8481110 0.8458859
## [141] 0.8444018 0.8421744 0.8399458 0.8384593 0.8369722 0.8347405 0.8302733
## [148] 0.8295283 0.8258012 0.8243094 0.8220708 0.8198309 0.8183371 0.8146002
## [155] 0.8123566 0.8078661 0.8055877 0.8040226 0.8016369 0.8016369 0.7991968
## [162] 0.7991968 0.7967353 0.7967353 0.7967353 0.7941807 0.7916244 0.7890471
## [169] 0.7890471 0.7890471 0.7890471 0.7890471 0.7890471 0.7890471 0.7890471
## [176] 0.7853603 0.7853603 0.7835068 0.7835068 0.7835068 0.7787221 0.7787221
## [183] 0.7787221 0.7787221 0.7787221 0.7757498 0.7757498 0.7757498 0.7757498
## [190] 0.7727012 0.7727012 0.7727012 0.7727012 0.7727012 0.7683891 0.7683891
## [197] 0.7683891 0.7683891 0.7683891 0.7683891 0.7672294 0.7672294 0.7672294
## [204] 0.7636829 0.7588940 0.7588940 0.7552787 0.7552787 0.7528027 0.7503240
## [211] 0.7503240 0.7452757 0.7452757 0.7427303 0.7427303 0.7375607 0.7375607
## [218] 0.7349535 0.7349535 0.7308945 0.7308945 0.7308945 0.7308945 0.7308945
## [225] 0.7308945 0.7308945 0.7308945 0.7308945 0.7308945 0.7308945 0.7308945
## [232] 0.7260265 0.7260265 0.7260265 0.7260265 0.7140753 0.7140753 0.7140753
## [239] 0.7140753 0.7140753 0.7140753 0.7140753 0.7140753 0.7103436 0.7103436
## [246] 0.7103436 0.7103436 0.7103436 0.7024807 0.7024807 0.7024807 0.7024807
## [253] 0.7024807 0.7024807 0.7024807 0.7024807 0.7024807 0.6956063 0.6956063
## [260] 0.6956063 0.6956063 0.6956063 0.6821050 0.6821050 0.6821050 0.6821050
## [267] 0.6821050 0.6821050 0.6821050 0.6821050 0.6821050 0.6821050 0.6740961
## [274] 0.6740961 0.6740961 0.6740961 0.6740961 0.6740961 0.6598316 0.6598316
## [281] 0.6598316 0.6598316 0.6598316 0.6598316 0.6598316 0.6598316 0.6598316
## [288] 0.6598316 0.6598316 0.6598316 0.6598316 0.6598316 0.6598316 0.6598316
## [295] 0.6598316
## 
## $t0
## [1] 0
## 
## $call
## survfit(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survfit"

## 
## ++++++++++++++++++++++++++ prev_infection ++++++++++++++++++++++++++
## $n
## [1] 863 542
## 
## $time
##   [1]  0.77  0.90  1.03  1.07  1.13  1.30  1.43  1.63  1.70  1.83  1.90  2.00
##  [13]  2.03  2.13  2.17  2.40  2.47  2.57  2.60  2.70  2.73  3.00  3.13  3.20
##  [25]  3.30  3.37  3.40  3.43  3.57  3.63  3.83  3.90  4.10  4.33  4.53  4.57
##  [37]  4.60  4.67  4.93  4.97  5.03  5.07  5.10  5.23  5.43  5.53  5.57  5.90
##  [49]  6.00  6.07  6.13  6.60  6.63  6.87  6.90  7.03  7.10  7.17  7.30  7.40
##  [61]  7.57  7.67  7.93  7.97  8.00  8.07  8.13  8.17  8.30  8.33  8.43  8.47
##  [73]  8.73  8.80  9.07  9.37  9.57  9.60  9.63  9.77  9.80  9.93 10.03 10.07
##  [85] 10.23 10.30 10.33 10.40 10.57 10.63 10.70 10.80 10.87 10.93 11.00 11.03
##  [97] 11.07 11.13 11.17 11.20 11.30 11.47 11.50 11.57 11.60 11.63 11.67 11.90
## [109] 11.93 12.07 12.20 12.23 12.27 12.30 12.33 12.37 12.43 12.47 12.50 12.53
## [121] 12.63 12.67 12.70 12.73 12.77 12.93 13.00 13.03 13.20 13.30 13.37 13.50
## [133] 13.60 13.70 13.73 13.87 13.90 13.93 14.07 14.10 14.13 14.17 14.20 14.30
## [145] 14.33 14.40 14.43 14.60 14.63 14.87 14.90 15.03 15.07 15.10 15.13 15.17
## [157] 15.33 15.47 15.50 15.53 15.57 15.60 15.70 15.77 15.80 15.93 15.97 16.00
## [169] 16.03 16.17 16.20 16.23 16.27 16.30 16.40 16.43 16.47 16.63 16.70 16.73
## [181] 16.93 16.97 17.00 17.03 17.20 17.23 17.27 17.33 17.37 17.63 17.67 17.80
## [193] 17.83 18.03 18.07 18.17 18.33 18.37 18.40 18.50 18.53 18.57 18.63 18.77
## [205] 18.80 19.03 19.07 19.27 19.53 19.57 19.80 19.93 20.50 20.67 21.13 21.40
## [217]  0.47  2.00  2.17  2.60  3.97  4.20  5.37  6.13  6.30  7.70  7.73  7.83
## [229]  8.47  9.33  9.57  9.67  9.73 10.23 10.60 11.07 11.30 11.93 12.23 12.27
## [241] 12.30 12.33 12.43 12.47 12.50 12.53 12.57 12.73 12.77 12.90 12.97 13.03
## [253] 13.10 13.13 13.20 13.23 13.27 13.37 13.40 13.43 13.47 13.50 13.60 13.83
## [265] 13.87 13.90 13.93 14.07 14.10 14.13 14.17 14.20 14.33 14.40 14.43 14.57
## [277] 14.60 14.63 14.70 14.83 15.03 15.10 15.27 15.37 15.60 15.90 15.93 15.97
## [289] 16.03 16.17 16.20 16.23 16.30 16.47 16.50 16.63 16.67 16.87 16.93 16.97
## [301] 17.10 17.17 17.20 17.23 17.37 17.40 17.43 17.57 17.67 17.70 17.80 17.83
## [313] 17.87 17.93 18.10 18.13 18.37 18.40 18.57 18.60 18.87 18.97 19.00 19.20
## [325] 19.27 19.57 19.70 19.77 19.80 20.23 20.27 20.40 20.63 20.87
## 
## $n.risk
##   [1] 863 862 861 860 858 857 856 854 853 852 851 850 849 848 847 846 845 842
##  [19] 841 840 839 838 837 834 831 828 826 824 823 821 820 819 817 815 813 811
##  [37] 810 808 807 806 804 803 801 799 797 795 793 789 787 785 783 782 780 779
##  [55] 778 776 774 771 763 760 757 755 753 748 744 742 739 736 734 731 729 728
##  [73] 726 723 720 718 714 711 708 705 702 699 694 691 688 682 678 675 672 669
##  [91] 667 662 659 657 654 652 649 647 645 643 640 637 636 631 629 626 623 620
## [109] 618 615 612 589 566 554 543 535 532 528 524 521 505 502 492 470 466 462
## [127] 455 447 440 423 418 413 402 399 395 387 384 378 374 368 365 361 357 353
## [145] 349 341 329 328 324 321 314 310 302 298 294 290 286 280 276 272 268 254
## [163] 250 247 245 242 239 233 230 222 219 216 213 210 207 204 200 192 189 185
## [181] 181 177 170 166 164 157 155 151 147 136 132 126 123 116 107 102  89  84
## [199]  75  72  69  66  63  61  58  53  48  45  41  36  31  23  20  15  10   4
## [217] 542 541 540 539 537 536 535 533 531 529 527 524 523 520 517 514 512 509
## [235] 507 504 501 498 496 483 473 469 465 457 444 440 439 436 432 428 425 421
## [253] 419 415 411 408 400 397 393 389 385 378 374 369 367 359 348 336 332 331
## [271] 327 323 319 313 309 306 302 298 291 287 284 280 276 272 268 264 260 256
## [289] 245 234 230 227 215 211 207 203 199 195 191 187 184 180 176 173 172 171
## [307] 165 161 157 154 146 138 134 128 116 111  93  84  79  72  67  65  60  56
## [325]  51  46  42  37  33  28  24  12   7   5
## 
## $n.event
##   [1] 1 1 1 2 1 1 2 1 1 0 1 1 1 1 1 1 3 1 1 1 1 1 3 3 3 2 2 1 2 1 1 2 2 2 2 1 2
##  [38] 1 1 2 1 2 2 2 2 2 4 2 2 2 1 2 1 1 2 2 3 8 3 3 2 2 2 4 2 3 3 2 3 2 1 2 3 3
##  [75] 2 4 3 3 3 3 3 5 3 3 6 4 3 3 3 2 5 3 2 3 2 3 2 2 2 3 3 1 5 2 3 3 3 2 3 3 6
## [112] 0 2 3 0 3 0 0 0 0 3 3 3 0 0 0 0 0 2 5 0 0 3 0 0 3 0 0 0 0 4 0 0 0 0 0 1 0
## [149] 3 3 0 0 2 2 0 4 2 4 0 0 2 0 3 0 0 0 0 0 0 0 0 0 3 0 3 0 0 3 0 0 0 0 0 2 0
## [186] 0 4 0 0 0 0 3 0 0 5 0 0 0 0 0 3 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 1 1 0 2 1 1
## [223] 2 2 2 2 3 1 3 3 3 2 3 2 3 3 3 2 3 0 0 0 0 3 0 1 0 0 0 0 0 0 4 0 0 0 0 0 0
## [260] 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4
## [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [334] 0
## 
## $n.censor
##   [1]  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [51]  0  0  0  0  0  0  0  0  0  0  0  0  3  0  0  0  0  0  0  0  0  0  0  0  0
##  [76]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [101]  0  0  0  0  0  0  0  0  0  0 17 23 10  8  8  0  4  4  3 16  0  7 19  4  4
## [126]  7  8  7 15  0  5 11  0  4  8  0  6  4  6  3  0  4  4  4  8 12  0  4  0  4
## [151]  4  8  2  2  4  0  4  0  4  4 12  4  0  2  3  3  6  3  8  3  3  3  0  3  0
## [176]  4  8  0  4  4  4  7  4  0  7  2  0  4 11  4  6  0  7  9  0 13  5  9  3  3
## [201]  0  3  0  3  5  5  0  4  5  5  8  3  5  5  6  4  0  0  1  0  0  0  0  0  0
## [226]  0  0  0  0  0  0  0  0  0  0  0  0  0 10 10  4  4  8 10  4  0  3  4  4  3
## [251]  4  2  0  4  3  8  3  4  4  4  7  4  5  2  8  7 12  4  1  4  4  4  6  4  3
## [276]  4  4  7  0  3  4  4  4  4  4  4  4 11 11  4  3 12  4  4  4  0  4  4  4  3
## [301]  4  4  3  1  1  6  4  4  3  8  8  4  6 12  5 18  9  5  7  5  2  5  4  5  5
## [326]  4  5  4  5  4 12  5  2  5
## 
## $surv
##   [1] 0.9988413 0.9976825 0.9965238 0.9942063 0.9930475 0.9918888 0.9895713
##   [8] 0.9884125 0.9872538 0.9872538 0.9860937 0.9849335 0.9837734 0.9826133
##  [15] 0.9814532 0.9802931 0.9768128 0.9756527 0.9744926 0.9733324 0.9721723
##  [22] 0.9710122 0.9675319 0.9640516 0.9605712 0.9582510 0.9559308 0.9547707
##  [29] 0.9524505 0.9512904 0.9501302 0.9478100 0.9454898 0.9431696 0.9408494
##  [36] 0.9396892 0.9373690 0.9362089 0.9350488 0.9327286 0.9315685 0.9292483
##  [43] 0.9269280 0.9246078 0.9222876 0.9199674 0.9153269 0.9130067 0.9106865
##  [50] 0.9083663 0.9072062 0.9048859 0.9037258 0.9025657 0.9002455 0.8979253
##  [57] 0.8944450 0.8851641 0.8816837 0.8782034 0.8758832 0.8735630 0.8712427
##  [64] 0.8665837 0.8642542 0.8607599 0.8572656 0.8549361 0.8514418 0.8491123
##  [71] 0.8479475 0.8456180 0.8421237 0.8386294 0.8362999 0.8316408 0.8281465
##  [78] 0.8246522 0.8211579 0.8176636 0.8141694 0.8083455 0.8048513 0.8013570
##  [85] 0.7943684 0.7897093 0.7862150 0.7827208 0.7792265 0.7768969 0.7710731
##  [92] 0.7675788 0.7652493 0.7617550 0.7594255 0.7559312 0.7536017 0.7512722
##  [99] 0.7489426 0.7454483 0.7419541 0.7407893 0.7349655 0.7326359 0.7291417
## [106] 0.7256474 0.7221531 0.7198236 0.7163293 0.7128350 0.7058464 0.7058464
## [113] 0.7033522 0.6995435 0.6995435 0.6956208 0.6956208 0.6956208 0.6956208
## [120] 0.6956208 0.6914884 0.6873560 0.6831648 0.6831648 0.6831648 0.6831648
## [127] 0.6831648 0.6831648 0.6800595 0.6720210 0.6720210 0.6720210 0.6670059
## [134] 0.6670059 0.6670059 0.6618353 0.6618353 0.6618353 0.6618353 0.6618353
## [141] 0.6545823 0.6545823 0.6545823 0.6545823 0.6545823 0.6545823 0.6525927
## [148] 0.6525927 0.6465502 0.6405077 0.6405077 0.6405077 0.6362659 0.6319956
## [155] 0.6319956 0.6232785 0.6189199 0.6100782 0.6100782 0.6100782 0.6055253
## [162] 0.6055253 0.5982590 0.5982590 0.5982590 0.5982590 0.5982590 0.5982590
## [169] 0.5982590 0.5982590 0.5982590 0.5982590 0.5898329 0.5898329 0.5812845
## [176] 0.5812845 0.5812845 0.5722020 0.5722020 0.5722020 0.5722020 0.5722020
## [183] 0.5722020 0.5653080 0.5653080 0.5653080 0.5507194 0.5507194 0.5507194
## [190] 0.5507194 0.5507194 0.5376070 0.5376070 0.5376070 0.5124852 0.5124852
## [197] 0.5124852 0.5124852 0.5124852 0.5124852 0.4902032 0.4902032 0.4746412
## [204] 0.4746412 0.4746412 0.4746412 0.4449761 0.4449761 0.4449761 0.4449761
## [211] 0.4449761 0.4449761 0.4449761 0.4449761 0.4449761 0.4449761 0.9981550
## [218] 0.9963100 0.9963100 0.9926131 0.9907646 0.9889162 0.9852193 0.9815224
## [225] 0.9778255 0.9741287 0.9685833 0.9667349 0.9611896 0.9556443 0.9500989
## [232] 0.9464020 0.9408567 0.9371598 0.9316145 0.9260692 0.9205239 0.9168270
## [239] 0.9112817 0.9112817 0.9112817 0.9112817 0.9112817 0.9052995 0.9052995
## [246] 0.9032420 0.9032420 0.9032420 0.9032420 0.9032420 0.9032420 0.9032420
## [253] 0.8946192 0.8946192 0.8946192 0.8946192 0.8946192 0.8946192 0.8946192
## [260] 0.8946192 0.8946192 0.8946192 0.8946192 0.8946192 0.8946192 0.8846513
## [267] 0.8846513 0.8846513 0.8846513 0.8846513 0.8846513 0.8846513 0.8846513
## [274] 0.8846513 0.8846513 0.8846513 0.8846513 0.8846513 0.8724911 0.8724911
## [281] 0.8724911 0.8724911 0.8724911 0.8724911 0.8724911 0.8724911 0.8724911
## [288] 0.8724911 0.8724911 0.8724911 0.8724911 0.8724911 0.8724911 0.8724911
## [295] 0.8724911 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992
## [302] 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992
## [309] 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992
## [316] 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992
## [323] 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992
## [330] 0.8552992 0.8552992 0.8552992 0.8552992 0.8552992
## 
## $std.err
##   [1] 0.001159420 0.001640620 0.002010509 0.002598579 0.002848261 0.003078270
##   [7] 0.003494515 0.003685701 0.003867864 0.003867864 0.004042626 0.004210527
##  [13] 0.004372359 0.004528773 0.004680313 0.004827441 0.005246017 0.005378929
##  [19] 0.005508941 0.005636253 0.005761047 0.005883483 0.006238029 0.006575840
##  [25] 0.006899399 0.007108164 0.007311940 0.007412089 0.007609141 0.007706130
##  [31] 0.007802144 0.007991398 0.008177170 0.008359697 0.008539195 0.008627870
##  [37] 0.008803181 0.008889860 0.008975914 0.009146220 0.009230506 0.009397430
##  [43] 0.009562254 0.009725090 0.009886044 0.010045212 0.010358540 0.010512862
##  [49] 0.010665720 0.010817183 0.010892411 0.011041898 0.011116172 0.011190142
##  [55] 0.011337197 0.011483114 0.011699961 0.012267364 0.012476446 0.012683698
##  [61] 0.012820903 0.012957372 0.013093134 0.013364797 0.013499654 0.013700793
##  [67] 0.013900626 0.014033160 0.014230981 0.014362238 0.014427686 0.014558236
##  [73] 0.014753224 0.014947262 0.015076121 0.015332710 0.015524224 0.015714997
##  [79] 0.015905077 0.016094508 0.016283333 0.016596806 0.016784212 0.016971156
##  [85] 0.017343801 0.017591419 0.017776761 0.017961821 0.018146627 0.018269705
##  [91] 0.018577023 0.018761195 0.018883903 0.019067872 0.019190469 0.019374308
##  [97] 0.019496841 0.019619362 0.019741877 0.019925656 0.020109462 0.020170741
## [103] 0.020477251 0.020599924 0.020784029 0.020968267 0.021152659 0.021275684
## [109] 0.021460383 0.021645293 0.022015830 0.022015830 0.022157662 0.022378334
## [115] 0.022378334 0.022612612 0.022612612 0.022612612 0.022612612 0.022612612
## [121] 0.022872780 0.023133098 0.023401061 0.023401061 0.023401061 0.023401061
## [127] 0.023401061 0.023401061 0.023621757 0.024212925 0.024212925 0.024212925
## [133] 0.024596122 0.024596122 0.024596122 0.025003131 0.025003131 0.025003131
## [139] 0.025003131 0.025003131 0.025603000 0.025603000 0.025603000 0.025603000
## [145] 0.025603000 0.025603000 0.025783336 0.025783336 0.026336770 0.026888934
## [151] 0.026888934 0.026888934 0.027296333 0.027708545 0.027708545 0.028565558
## [157] 0.028993351 0.029872633 0.029872633 0.029872633 0.030338580 0.030338580
## [163] 0.031128965 0.031128965 0.031128965 0.031128965 0.031128965 0.031128965
## [169] 0.031128965 0.031128965 0.031128965 0.031128965 0.032188220 0.032188220
## [175] 0.033273479 0.033273479 0.033273479 0.034493425 0.034493425 0.034493425
## [181] 0.034493425 0.034493425 0.034493425 0.035542383 0.035542383 0.035542383
## [187] 0.037870366 0.037870366 0.037870366 0.037870366 0.037870366 0.040345235
## [193] 0.040345235 0.040345235 0.045671273 0.045671273 0.045671273 0.045671273
## [199] 0.045671273 0.045671273 0.052389185 0.052389185 0.057140646 0.057140646
## [205] 0.057140646 0.057140646 0.068219809 0.068219809 0.068219809 0.068219809
## [211] 0.068219809 0.068219809 0.068219809 0.068219809 0.068219809 0.068219809
## [217] 0.001846723 0.002614078 0.002614078 0.003707186 0.004149394 0.004550243
## [223] 0.005264830 0.005897881 0.006473407 0.007005643 0.007742272 0.007974442
## [229] 0.008638446 0.009261847 0.009852468 0.010230876 0.010778793 0.011132494
## [235] 0.011647867 0.012147173 0.012632417 0.012948933 0.013414298 0.013414298
## [241] 0.013414298 0.013414298 0.013414298 0.013942839 0.013942839 0.014127272
## [247] 0.014127272 0.014127272 0.014127272 0.014127272 0.014127272 0.014127272
## [253] 0.014919233 0.014919233 0.014919233 0.014919233 0.014919233 0.014919233
## [259] 0.014919233 0.014919233 0.014919233 0.014919233 0.014919233 0.014919233
## [265] 0.014919233 0.015936424 0.015936424 0.015936424 0.015936424 0.015936424
## [271] 0.015936424 0.015936424 0.015936424 0.015936424 0.015936424 0.015936424
## [277] 0.015936424 0.015936424 0.017374235 0.017374235 0.017374235 0.017374235
## [283] 0.017374235 0.017374235 0.017374235 0.017374235 0.017374235 0.017374235
## [289] 0.017374235 0.017374235 0.017374235 0.017374235 0.017374235 0.017374235
## [295] 0.017374235 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021
## [301] 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021
## [307] 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021
## [313] 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021
## [319] 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021
## [325] 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021 0.020022021
## [331] 0.020022021 0.020022021 0.020022021 0.020022021
## 
## $cumhaz
##   [1] 0.001158749 0.002318841 0.003480282 0.005805863 0.006971364 0.008138225
##   [7] 0.010474674 0.011645634 0.012817967 0.012817967 0.013993055 0.015169526
##  [13] 0.016347382 0.017526627 0.018707265 0.019889298 0.023439594 0.024627242
##  [19] 0.025816303 0.027006779 0.028198674 0.029391992 0.032976221 0.036573343
##  [25] 0.040183452 0.042598911 0.045020218 0.046233810 0.048663944 0.049881971
##  [31] 0.051101483 0.053543485 0.055991466 0.058445454 0.060905478 0.062138524
##  [37] 0.064607660 0.065845283 0.067084441 0.069565830 0.070809611 0.073300271
##  [43] 0.075797150 0.078300279 0.080809689 0.083325413 0.088369549 0.090904403
##  [49] 0.093445699 0.095993470 0.097270609 0.099828154 0.101110205 0.102393902
##  [55] 0.104964596 0.107541916 0.111417885 0.121794020 0.125725868 0.129673236
##  [61] 0.132315244 0.134964251 0.137620293 0.142967887 0.145656059 0.149699186
##  [67] 0.153758725 0.156476117 0.160563310 0.163299288 0.164671030 0.167418283
##  [73] 0.171550515 0.175699892 0.178477670 0.184048701 0.188250381 0.192469791
##  [79] 0.196707079 0.200962398 0.205235902 0.212388978 0.216711745 0.221053279
##  [85] 0.229774209 0.235639311 0.240064090 0.244508535 0.248972820 0.251962357
##  [91] 0.259458609 0.263990331 0.267025232 0.271591442 0.274649546 0.279250773
##  [97] 0.282332437 0.285423627 0.288524403 0.293190033 0.297877533 0.299447391
## [103] 0.307309026 0.310478599 0.315248074 0.320040406 0.324855815 0.328081622
## [109] 0.332935991 0.337814040 0.347617961 0.347617961 0.351151530 0.356566693
## [115] 0.356566693 0.362174169 0.362174169 0.362174169 0.362174169 0.362174169
## [121] 0.368114763 0.374090859 0.380188420 0.380188420 0.380188420 0.380188420
## [127] 0.380188420 0.380188420 0.384733874 0.396554205 0.396554205 0.396554205
## [133] 0.404016892 0.404016892 0.404016892 0.411768830 0.411768830 0.411768830
## [139] 0.411768830 0.411768830 0.422727734 0.422727734 0.422727734 0.422727734
## [145] 0.422727734 0.422727734 0.425767248 0.425767248 0.435026507 0.444372301
## [151] 0.444372301 0.444372301 0.450994818 0.457706227 0.457706227 0.471499331
## [157] 0.478492338 0.492778052 0.492778052 0.492778052 0.500240739 0.500240739
## [163] 0.512240739 0.512240739 0.512240739 0.512240739 0.512240739 0.512240739
## [169] 0.512240739 0.512240739 0.512240739 0.512240739 0.526325246 0.526325246
## [175] 0.540817999 0.540817999 0.540817999 0.556442999 0.556442999 0.556442999
## [181] 0.556442999 0.556442999 0.556442999 0.568491192 0.568491192 0.568491192
## [187] 0.594297644 0.594297644 0.594297644 0.594297644 0.594297644 0.618107167
## [193] 0.618107167 0.618107167 0.664836139 0.664836139 0.664836139 0.664836139
## [199] 0.664836139 0.664836139 0.708314400 0.708314400 0.740060432 0.740060432
## [205] 0.740060432 0.740060432 0.802560432 0.802560432 0.802560432 0.802560432
## [211] 0.802560432 0.802560432 0.802560432 0.802560432 0.802560432 0.802560432
## [217] 0.001845018 0.003693447 0.003693447 0.007404022 0.009266220 0.011131891
## [223] 0.014870209 0.018622554 0.022389033 0.026169751 0.031862351 0.033770748
## [229] 0.039506885 0.045276116 0.051078824 0.054969875 0.060829250 0.064758523
## [235] 0.070675682 0.076628063 0.082616087 0.086632152 0.092680539 0.092680539
## [241] 0.092680539 0.092680539 0.092680539 0.099245090 0.099245090 0.101517817
## [247] 0.101517817 0.101517817 0.101517817 0.101517817 0.101517817 0.101517817
## [253] 0.111064357 0.111064357 0.111064357 0.111064357 0.111064357 0.111064357
## [259] 0.111064357 0.111064357 0.111064357 0.111064357 0.111064357 0.111064357
## [265] 0.111064357 0.122206418 0.122206418 0.122206418 0.122206418 0.122206418
## [271] 0.122206418 0.122206418 0.122206418 0.122206418 0.122206418 0.122206418
## [277] 0.122206418 0.122206418 0.135952123 0.135952123 0.135952123 0.135952123
## [283] 0.135952123 0.135952123 0.135952123 0.135952123 0.135952123 0.135952123
## [289] 0.135952123 0.135952123 0.135952123 0.135952123 0.135952123 0.135952123
## [295] 0.135952123 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556
## [301] 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556
## [307] 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556
## [313] 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556
## [319] 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556
## [325] 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556 0.155656556
## [331] 0.155656556 0.155656556 0.155656556 0.155656556
## 
## $std.chaz
##   [1] 0.001158749 0.001639669 0.002009342 0.002596463 0.002846052 0.003075968
##   [7] 0.003491572 0.003682692 0.003864788 0.003864788 0.004039483 0.004207315
##  [13] 0.004369079 0.004525425 0.004676898 0.004823958 0.005241384 0.005374255
##  [19] 0.005504224 0.005631493 0.005756243 0.005878634 0.006232220 0.006569145
##  [25] 0.006891876 0.007100365 0.007303872 0.007404009 0.007600798 0.007697773
##  [31] 0.007793775 0.007982770 0.008168287 0.008350566 0.008529819 0.008618481
##  [37] 0.008793550 0.008880216 0.008966256 0.009136323 0.009220596 0.009387283
##  [43] 0.009551873 0.009714479 0.009875205 0.010034147 0.010346252 0.010500366
##  [49] 0.010653017 0.010804274 0.010879496 0.011028778 0.011103045 0.011177007
##  [55] 0.011323856 0.011469568 0.011685834 0.012248132 0.012456720 0.012663482
##  [61] 0.012800542 0.012936866 0.013072482 0.013343125 0.013477838 0.013678489
##  [67] 0.013877837 0.014010227 0.014207563 0.014338676 0.014404142 0.014534545
##  [73] 0.014729046 0.014922597 0.015051310 0.015306894 0.015497926 0.015688218
##  [79] 0.015877817 0.016066766 0.016255110 0.016566891 0.016753825 0.016940296
##  [85] 0.017310384 0.017557029 0.017741913 0.017926512 0.018110857 0.018233809
##  [91] 0.018539432 0.018723142 0.018845725 0.019029226 0.019151696 0.019335060
##  [97] 0.019457463 0.019579852 0.019702234 0.019885524 0.020068838 0.020130145
## [103] 0.020434867 0.020557404 0.020741010 0.020924746 0.021108633 0.021231517
## [109] 0.021415701 0.021600094 0.021967784 0.021967784 0.022109423 0.022329381
## [115] 0.022329381 0.022562857 0.022562857 0.022562857 0.022562857 0.022562857
## [121] 0.022822052 0.023081392 0.023348320 0.023348320 0.023348320 0.023348320
## [127] 0.023348320 0.023348320 0.023568509 0.024154061 0.024154061 0.024154061
## [133] 0.024535333 0.024535333 0.024535333 0.024940197 0.024940197 0.024940197
## [139] 0.024940197 0.024940197 0.025535031 0.025535031 0.025535031 0.025535031
## [145] 0.025535031 0.025535031 0.025715296 0.025715296 0.026265080 0.026813598
## [151] 0.026813598 0.026813598 0.027219440 0.027630045 0.027630045 0.028477743
## [157] 0.028903856 0.029773366 0.029773366 0.029773366 0.030237380 0.030237380
## [163] 0.031020947 0.031020947 0.031020947 0.031020947 0.031020947 0.031020947
## [169] 0.031020947 0.031020947 0.031020947 0.031020947 0.032069044 0.032069044
## [175] 0.033142675 0.033142675 0.033142675 0.034348466 0.034348466 0.034348466
## [181] 0.034348466 0.034348466 0.034348466 0.035389216 0.035389216 0.035389216
## [187] 0.037668154 0.037668154 0.037668154 0.037668154 0.037668154 0.040098059
## [193] 0.040098059 0.040098059 0.045216962 0.045216962 0.045216962 0.045216962
## [199] 0.045216962 0.045216962 0.051717438 0.051717438 0.056379062 0.056379062
## [205] 0.056379062 0.056379062 0.066937897 0.066937897 0.066937897 0.066937897
## [211] 0.066937897 0.066937897 0.066937897 0.066937897 0.066937897 0.066937897
## [217] 0.001845018 0.002611663 0.002611663 0.003702022 0.004144001 0.004544610
## [223] 0.005257470 0.005889060 0.006463297 0.006994364 0.007728067 0.007960214
## [229] 0.008621645 0.009242696 0.009831136 0.010208887 0.010754788 0.011107883
## [235] 0.011621359 0.012118840 0.012602318 0.012918313 0.013381970 0.013381970
## [241] 0.013381970 0.013381970 0.013381970 0.013908328 0.013908328 0.014092795
## [247] 0.014092795 0.014092795 0.014092795 0.014092795 0.014092795 0.014092795
## [253] 0.014879213 0.014879213 0.014879213 0.014879213 0.014879213 0.014879213
## [259] 0.014879213 0.014879213 0.014879213 0.014879213 0.014879213 0.014879213
## [265] 0.014879213 0.015887962 0.015887962 0.015887962 0.015887962 0.015887962
## [271] 0.015887962 0.015887962 0.015887962 0.015887962 0.015887962 0.015887962
## [277] 0.015887962 0.015887962 0.017310790 0.017310790 0.017310790 0.017310790
## [283] 0.017310790 0.017310790 0.017310790 0.017310790 0.017310790 0.017310790
## [289] 0.017310790 0.017310790 0.017310790 0.017310790 0.017310790 0.017310790
## [295] 0.017310790 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073
## [301] 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073
## [307] 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073
## [313] 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073
## [319] 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073
## [325] 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073 0.019918073
## [331] 0.019918073 0.019918073 0.019918073 0.019918073
## 
## $strata
##   get(cat)=AIDS get(cat)=noAIDS 
##             216             118 
## 
## $type
## [1] "right"
## 
## $logse
## [1] TRUE
## 
## $conf.int
## [1] 0.95
## 
## $conf.type
## [1] "log"
## 
## $lower
##   [1] 0.9965740 0.9944796 0.9926047 0.9891555 0.9875193 0.9859224 0.9828167
##   [8] 0.9812981 0.9797978 0.9797978 0.9783113 0.9768388 0.9753788 0.9739300
##  [15] 0.9724913 0.9710617 0.9668206 0.9654209 0.9640272 0.9626394 0.9612568
##  [22] 0.9598794 0.9557746 0.9517062 0.9476693 0.9449935 0.9423289 0.9410006
##  [29] 0.9383513 0.9370303 0.9357114 0.9330803 0.9304573 0.9278419 0.9252339
##  [36] 0.9239324 0.9213345 0.9200379 0.9187428 0.9161572 0.9148666 0.9122894
##  [43] 0.9097176 0.9071509 0.9045891 0.9020320 0.8969310 0.8943869 0.8918467
##  [50] 0.8893105 0.8880437 0.8855130 0.8842490 0.8829859 0.8804622 0.8779419
##  [57] 0.8741674 0.8641354 0.8603851 0.8566408 0.8541478 0.8516573 0.8491693
##  [64] 0.8441787 0.8416869 0.8379534 0.8342249 0.8317419 0.8280213 0.8255435
##  [71] 0.8243053 0.8218304 0.8181217 0.8144172 0.8119498 0.8070205 0.8033281
##  [78] 0.7996394 0.7959545 0.7922733 0.7885956 0.7824738 0.7788053 0.7751400
##  [85] 0.7678190 0.7629453 0.7592936 0.7556448 0.7519990 0.7495700 0.7435031
##  [92] 0.7398666 0.7374438 0.7338119 0.7313920 0.7277644 0.7253475 0.7229317
##  [99] 0.7205170 0.7168971 0.7132796 0.7120743 0.7060520 0.7036449 0.7000362
## [106] 0.6964299 0.6928259 0.6904244 0.6868242 0.6832262 0.6760367 0.6760367
## [113] 0.6734607 0.6695241 0.6695241 0.6654642 0.6654642 0.6654642 0.6654642
## [120] 0.6654642 0.6611737 0.6568872 0.6525390 0.6525390 0.6525390 0.6525390
## [127] 0.6525390 0.6525390 0.6492920 0.6408741 0.6408741 0.6408741 0.6356139
## [134] 0.6356139 0.6356139 0.6301838 0.6301838 0.6301838 0.6301838 0.6301838
## [141] 0.6225453 0.6225453 0.6225453 0.6225453 0.6225453 0.6225453 0.6204337
## [148] 0.6204337 0.6140226 0.6076261 0.6076261 0.6076261 0.6031203 0.5985887
## [155] 0.5985887 0.5893416 0.5847298 0.5753841 0.5753841 0.5753841 0.5705689
## [162] 0.5705689 0.5628494 0.5628494 0.5628494 0.5628494 0.5628494 0.5628494
## [169] 0.5628494 0.5628494 0.5628494 0.5628494 0.5537711 0.5537711 0.5445858
## [176] 0.5445858 0.5445858 0.5347964 0.5347964 0.5347964 0.5347964 0.5347964
## [183] 0.5347964 0.5272680 0.5272680 0.5272680 0.5113227 0.5113227 0.5113227
## [190] 0.5113227 0.5113227 0.4967330 0.4967330 0.4967330 0.4686039 0.4686039
## [197] 0.4686039 0.4686039 0.4686039 0.4686039 0.4423667 0.4423667 0.4243530
## [204] 0.4243530 0.4243530 0.4243530 0.3892852 0.3892852 0.3892852 0.3892852
## [211] 0.3892852 0.3892852 0.3892852 0.3892852 0.3892852 0.3892852 0.9945487
## [218] 0.9912184 0.9912184 0.9854269 0.9827398 0.9801359 0.9751052 0.9702417
## [225] 0.9654976 0.9608445 0.9539965 0.9517427 0.9450526 0.9384531 0.9319281
## [232] 0.9276137 0.9211886 0.9169331 0.9105872 0.9042817 0.8980124 0.8938512
## [239] 0.8876349 0.8876349 0.8876349 0.8876349 0.8876349 0.8808949 0.8808949
## [246] 0.8785753 0.8785753 0.8785753 0.8785753 0.8785753 0.8785753 0.8785753
## [253] 0.8688382 0.8688382 0.8688382 0.8688382 0.8688382 0.8688382 0.8688382
## [260] 0.8688382 0.8688382 0.8688382 0.8688382 0.8688382 0.8688382 0.8574464
## [267] 0.8574464 0.8574464 0.8574464 0.8574464 0.8574464 0.8574464 0.8574464
## [274] 0.8574464 0.8574464 0.8574464 0.8574464 0.8574464 0.8432805 0.8432805
## [281] 0.8432805 0.8432805 0.8432805 0.8432805 0.8432805 0.8432805 0.8432805
## [288] 0.8432805 0.8432805 0.8432805 0.8432805 0.8432805 0.8432805 0.8432805
## [295] 0.8432805 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852
## [302] 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852
## [309] 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852
## [316] 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852
## [323] 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852
## [330] 0.8223852 0.8223852 0.8223852 0.8223852 0.8223852
## 
## $upper
##   [1] 1.0000000 1.0000000 1.0000000 0.9992828 0.9986067 0.9978912 0.9963722
##   [8] 0.9955785 0.9947665 0.9947665 0.9939379 0.9930953 0.9922403 0.9913741
##  [15] 0.9904977 0.9896123 0.9869082 0.9859929 0.9850715 0.9841443 0.9832118
##  [22] 0.9822742 0.9794338 0.9765571 0.9736488 0.9716945 0.9697290 0.9687423
##  [29] 0.9667614 0.9657674 0.9647712 0.9627723 0.9607652 0.9587504 0.9567284
##  [36] 0.9557148 0.9536826 0.9526642 0.9516442 0.9495997 0.9485753 0.9465223
##  [43] 0.9444640 0.9424006 0.9403324 0.9382594 0.9341002 0.9320142 0.9299243
##  [50] 0.9278304 0.9267821 0.9246827 0.9236316 0.9225797 0.9204733 0.9183636
##  [57] 0.9151929 0.9067045 0.9035097 0.9003088 0.8981717 0.8960321 0.8938900
##  [64] 0.8895834 0.8874265 0.8841871 0.8809426 0.8787770 0.8755247 0.8733539
##  [71] 0.8722678 0.8700940 0.8668298 0.8635614 0.8613801 0.8570122 0.8537317
##  [78] 0.8504474 0.8471594 0.8438677 0.8405725 0.8350727 0.8317683 0.8284607
##  [85] 0.8218357 0.8174122 0.8140910 0.8107668 0.8074398 0.8052201 0.7996655
##  [92] 0.7963290 0.7941032 0.7907623 0.7885335 0.7851881 0.7829564 0.7807236
##  [99] 0.7784897 0.7751367 0.7717812 0.7706622 0.7650630 0.7628215 0.7594572
## [106] 0.7560906 0.7527217 0.7504745 0.7471018 0.7437269 0.7369705 0.7369705
## [113] 0.7345705 0.7309088 0.7309088 0.7271440 0.7271440 0.7271440 0.7271440
## [120] 0.7271440 0.7231931 0.7192381 0.7152280 0.7152280 0.7152280 0.7152280
## [127] 0.7152280 0.7152280 0.7122850 0.7046816 0.7046816 0.7046816 0.6999482
## [134] 0.6999482 0.6999482 0.6950766 0.6950766 0.6950766 0.6950766 0.6950766
## [141] 0.6882680 0.6882680 0.6882680 0.6882680 0.6882680 0.6882680 0.6864186
## [148] 0.6864186 0.6808009 0.6751686 0.6751686 0.6751686 0.6712330 0.6672670
## [155] 0.6672670 0.6591696 0.6551091 0.6468642 0.6468642 0.6468642 0.6426234
## [162] 0.6426234 0.6358963 0.6358963 0.6358963 0.6358963 0.6358963 0.6358963
## [169] 0.6358963 0.6358963 0.6358963 0.6358963 0.6282429 0.6282429 0.6204563
## [176] 0.6204563 0.6204563 0.6122238 0.6122238 0.6122238 0.6122238 0.6122238
## [183] 0.6122238 0.6060924 0.6060924 0.6060924 0.5931516 0.5931516 0.5931516
## [190] 0.5931516 0.5931516 0.5818444 0.5818444 0.5818444 0.5604757 0.5604757
## [197] 0.5604757 0.5604757 0.5604757 0.5604757 0.5432127 0.5432127 0.5308889
## [204] 0.5308889 0.5308889 0.5308889 0.5086342 0.5086342 0.5086342 0.5086342
## [211] 0.5086342 0.5086342 0.5086342 0.5086342 0.5086342 0.5086342 1.0000000
## [218] 1.0000000 1.0000000 0.9998516 0.9988550 0.9977751 0.9954383 0.9929343
## [225] 0.9903109 0.9875965 0.9833933 0.9819633 0.9776021 0.9731504 0.9686241
## [232] 0.9655710 0.9609447 0.9578327 0.9531273 0.9483816 0.9435997 0.9403933
## [239] 0.9355584 0.9355584 0.9355584 0.9355584 0.9355584 0.9303802 0.9303802
## [246] 0.9286013 0.9286013 0.9286013 0.9286013 0.9286013 0.9286013 0.9286013
## [253] 0.9211651 0.9211651 0.9211651 0.9211651 0.9211651 0.9211651 0.9211651
## [260] 0.9211651 0.9211651 0.9211651 0.9211651 0.9211651 0.9211651 0.9127193
## [267] 0.9127193 0.9127193 0.9127193 0.9127193 0.9127193 0.9127193 0.9127193
## [274] 0.9127193 0.9127193 0.9127193 0.9127193 0.9127193 0.9027136 0.9027136
## [281] 0.9027136 0.9027136 0.9027136 0.9027136 0.9027136 0.9027136 0.9027136
## [288] 0.9027136 0.9027136 0.9027136 0.9027136 0.9027136 0.9027136 0.9027136
## [295] 0.9027136 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305
## [302] 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305
## [309] 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305
## [316] 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305
## [323] 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305
## [330] 0.8895305 0.8895305 0.8895305 0.8895305 0.8895305
## 
## $t0
## [1] 0
## 
## $call
## survfit(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survfit"

## 
## ++++++++++++++++++++++++++ azt ++++++++++++++++++++++++++
## $n
## [1] 491 914
## 
## $time
##   [1]  0.77  0.90  1.07  1.13  1.43  1.63  1.90  2.03  2.47  2.57  2.60  3.13
##  [13]  3.20  3.30  3.43  3.57  3.63  3.90  4.10  4.33  4.53  4.57  4.60  4.67
##  [25]  4.93  5.03  5.10  5.43  5.57  5.90  6.07  6.13  6.60  6.63  6.87  6.90
##  [37]  7.03  7.97  8.00  8.33  8.43  8.47  8.73  8.80  9.07  9.37  9.57  9.60
##  [49]  9.63  9.77  9.80  9.93 10.03 10.07 10.23 10.30 10.33 10.40 10.70 10.80
##  [61] 10.87 11.03 11.07 11.13 11.30 11.50 11.57 11.60 11.63 11.67 12.07 12.20
##  [73] 12.23 12.27 12.30 12.33 12.37 12.50 12.53 12.67 12.70 12.93 13.00 13.03
##  [85] 13.20 13.30 13.37 13.73 13.90 14.07 14.13 14.17 14.30 14.40 14.43 15.03
##  [97] 15.10 15.13 15.33 15.50 15.53 15.57 15.70 15.80 15.93 16.03 16.17 16.20
## [109] 16.23 16.30 16.40 16.63 16.70 16.97 17.00 17.03 17.20 17.23 17.27 17.33
## [121] 17.63 17.67 17.80 17.83 18.03 18.07 18.13 18.17 18.37 18.40 18.57 18.63
## [133] 18.77 18.80 19.03 19.07 19.27 19.53 19.57 19.93 20.50 21.13 21.40  0.47
## [145]  1.03  1.07  1.30  1.43  1.70  1.83  2.00  2.13  2.17  2.40  2.60  2.70
## [157]  2.73  3.00  3.13  3.20  3.37  3.40  3.83  3.97  4.20  4.53  4.97  5.07
## [169]  5.23  5.37  5.53  5.57  6.00  6.13  6.30  7.10  7.17  7.30  7.40  7.57
## [181]  7.67  7.70  7.73  7.83  7.93  7.97  8.07  8.13  8.17  8.30  8.47  9.33
## [193]  9.57  9.67  9.73  9.93 10.23 10.57 10.60 10.63 10.70 10.93 11.00 11.07
## [205] 11.17 11.20 11.30 11.47 11.90 11.93 12.20 12.23 12.27 12.30 12.33 12.43
## [217] 12.47 12.50 12.53 12.57 12.63 12.67 12.70 12.73 12.77 12.90 12.97 13.00
## [229] 13.03 13.10 13.13 13.20 13.23 13.27 13.37 13.40 13.43 13.47 13.50 13.60
## [241] 13.70 13.73 13.83 13.87 13.90 13.93 14.07 14.10 14.13 14.17 14.20 14.33
## [253] 14.40 14.43 14.57 14.60 14.63 14.70 14.83 14.87 14.90 15.03 15.07 15.10
## [265] 15.17 15.27 15.33 15.37 15.47 15.57 15.60 15.77 15.90 15.93 15.97 16.00
## [277] 16.03 16.17 16.20 16.23 16.27 16.30 16.43 16.47 16.50 16.63 16.67 16.73
## [289] 16.87 16.93 16.97 17.10 17.17 17.20 17.23 17.37 17.40 17.43 17.57 17.67
## [301] 17.70 17.80 17.83 17.87 17.93 18.10 18.13 18.17 18.33 18.37 18.40 18.50
## [313] 18.53 18.57 18.60 18.87 18.97 19.00 19.20 19.27 19.57 19.70 19.77 19.80
## [325] 20.23 20.27 20.40 20.63 20.67 20.87 21.13
## 
## $n.risk
##   [1] 491 490 489 488 487 486 485 484 483 480 479 478 477 476 473 472 470 469
##  [19] 467 465 463 462 461 459 458 457 456 454 452 450 448 446 445 443 442 441
##  [37] 439 437 436 434 432 431 429 426 423 421 417 414 411 408 405 402 399 396
##  [55] 393 390 386 383 380 378 375 373 370 368 366 363 358 356 353 350 347 344
##  [73] 332 317 313 304 296 293 290 282 275 264 257 253 250 240 235 232 228 226
##  [91] 223 219 215 211 203 202 194 190 186 182 178 174 168 165 162 159 151 148
## [109] 145 142 139 136 133 129 125 121 119 115 113 109 105 101  97  94  91  82
## [127]  77  72  63  54  51  48  46  43  38  33  30  26  21  16  13   8   4 914
## [145] 913 912 911 910 909 908 907 905 904 902 901 899 898 897 896 894 892 890
## [163] 888 887 886 885 884 882 880 878 876 874 872 870 868 866 863 855 852 849
## [181] 847 845 843 840 839 834 831 828 825 823 820 817 814 811 809 806 804 799
## [199] 796 793 791 788 785 783 780 778 775 772 771 769 764 753 732 714 708 704
## [217] 692 675 671 662 659 656 653 642 634 626 623 619 615 609 605 601 591 583
## [235] 580 574 570 566 559 544 536 532 528 526 515 500 484 477 473 469 465 457
## [253] 443 435 432 428 420 410 406 403 396 392 388 384 380 376 372 370 366 362
## [271] 354 346 344 340 336 319 316 305 301 298 286 283 279 275 263 259 255 251
## [289] 247 243 235 229 225 221 215 214 202 196 192 188 183 175 167 159 153 141
## [307] 136 123 119 114 105 100  97  94  87  82  80  75  71  66  61  57  52  48
## [325]  35  31  19  14  12   7   2
## 
## $n.event
##   [1] 1 1 1 1 1 1 1 1 3 1 1 1 1 3 1 2 1 2 2 2 1 1 2 1 1 1 2 2 2 2 2 1 2 1 1 2 2
##  [38] 1 2 2 1 2 3 3 2 4 3 3 3 3 3 3 3 3 3 4 3 3 2 3 2 3 2 2 3 5 2 3 3 3 3 3 0 0
##  [75] 3 0 3 0 0 3 3 0 0 0 2 5 0 0 0 0 4 0 0 0 1 0 2 0 0 0 0 2 3 0 0 0 0 0 0 0 3
## [112] 3 0 0 0 2 0 0 4 0 0 0 3 0 0 5 0 0 0 0 0 2 0 0 0 3 0 0 0 0 0 0 0 1 1 1 1 1
## [149] 1 0 2 1 1 1 2 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 2 3 8 3 3 2 2 2 3 1 2
## [186] 3 3 3 2 3 3 3 3 2 3 2 5 3 3 2 3 3 2 3 2 3 3 1 2 5 3 3 2 0 0 0 3 0 1 0 3 0
## [223] 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 3 0 0 0 3 4 0 0 0 0 0 0 0 0 0 0 0 3 4 0
## [260] 3 0 0 2 0 4 0 2 0 4 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0
## [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## 
## $n.censor
##   [1]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
##  [51]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  9 15  4  6
##  [76]  8  0  3  8  4  8  7  4  3  8  0  3  4  2  3  0  4  4  8  0  8  2  4  4  4
## [101]  4  4  0  3  3  8  3  3  3  3  0  0  4  4  4  0  4  2  0  4  4  4  0  3  9
## [126]  0  5  9  9  3  3  0  3  5  5  0  4  5  5  3  5  4  4  0  0  0  0  0  0  1
## [151]  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [176]  0  0  0  0  0  0  0  0  0  3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## [201]  0  0  0  0  0  0  0  0  0  0  8 18 16  6  4 12 14  4  8  3  0  3 11  8  8
## [226]  3  4  4  6  0  4 10  8  3  6  4  4  7 15  5  4  4  2  8 11 16  7  4  4  4
## [251]  8 14  8  3  4  8  7  0  3  4  4  4  2  4  0  4  0  4  0  8  8  2  4  4 17
## [276]  3 11  4  3 12  0  4  4 12  4  0  4  4  4  8  6  4  4  6  1 12  6  4  4  5
## [301]  8  8  8  6 12  5 13  4  5  9  5  3  0  7  5  2  5  4  5  5  4  5  4 13  4
## [326] 12  5  2  5  5  2
## 
## $surv
##   [1] 0.9979633 0.9959267 0.9938900 0.9918534 0.9898167 0.9877800 0.9857434
##   [8] 0.9837067 0.9775967 0.9755601 0.9735234 0.9714868 0.9694501 0.9633401
##  [15] 0.9613035 0.9572301 0.9551935 0.9511202 0.9470468 0.9429735 0.9409369
##  [22] 0.9389002 0.9348269 0.9327902 0.9307536 0.9287169 0.9246436 0.9205703
##  [29] 0.9164969 0.9124236 0.9083503 0.9063136 0.9022403 0.9002037 0.8981670
##  [36] 0.8940937 0.8900204 0.8879837 0.8839104 0.8798371 0.8778004 0.8737271
##  [43] 0.8676171 0.8615071 0.8574338 0.8492872 0.8431772 0.8370672 0.8309572
##  [50] 0.8248473 0.8187373 0.8126273 0.8065173 0.8004073 0.7942974 0.7861507
##  [57] 0.7800407 0.7739308 0.7698574 0.7637475 0.7596741 0.7535642 0.7494908
##  [64] 0.7454175 0.7393075 0.7291242 0.7250509 0.7189409 0.7128310 0.7067210
##  [71] 0.7006110 0.6945010 0.6945010 0.6945010 0.6878445 0.6878445 0.6808731
##  [78] 0.6808731 0.6808731 0.6736297 0.6662810 0.6662810 0.6662810 0.6662810
##  [85] 0.6609508 0.6471810 0.6471810 0.6471810 0.6471810 0.6471810 0.6355724
##  [92] 0.6355724 0.6355724 0.6355724 0.6324415 0.6324415 0.6259214 0.6259214
##  [99] 0.6259214 0.6259214 0.6259214 0.6187269 0.6076783 0.6076783 0.6076783
## [106] 0.6076783 0.6076783 0.6076783 0.6076783 0.6076783 0.5945629 0.5814475
## [113] 0.5814475 0.5814475 0.5814475 0.5718368 0.5718368 0.5718368 0.5515948
## [120] 0.5515948 0.5515948 0.5515948 0.5345352 0.5345352 0.5345352 0.5019416
## [127] 0.5019416 0.5019416 0.5019416 0.5019416 0.5019416 0.4810273 0.4810273
## [134] 0.4810273 0.4810273 0.4372976 0.4372976 0.4372976 0.4372976 0.4372976
## [141] 0.4372976 0.4372976 0.4372976 0.9989059 0.9978118 0.9967177 0.9956236
## [148] 0.9945295 0.9934354 0.9934354 0.9912449 0.9901496 0.9890543 0.9879577
## [155] 0.9857647 0.9846682 0.9835717 0.9824752 0.9802822 0.9780891 0.9758961
## [162] 0.9737031 0.9726066 0.9715101 0.9704135 0.9693170 0.9671240 0.9649310
## [169] 0.9627380 0.9605449 0.9583519 0.9561589 0.9539659 0.9517728 0.9495798
## [176] 0.9462903 0.9375182 0.9342286 0.9309391 0.9287461 0.9265530 0.9243600
## [183] 0.9210705 0.9199740 0.9177809 0.9144796 0.9111782 0.9078768 0.9056759
## [190] 0.9023745 0.8990732 0.8957718 0.8924704 0.8902695 0.8869682 0.8847672
## [197] 0.8792650 0.8759636 0.8726622 0.8704613 0.8671599 0.8638586 0.8616576
## [204] 0.8583563 0.8561554 0.8528540 0.8495526 0.8484522 0.8462513 0.8407490
## [211] 0.8374476 0.8341112 0.8318322 0.8318322 0.8318322 0.8318322 0.8282260
## [218] 0.8282260 0.8269916 0.8269916 0.8232269 0.8232269 0.8232269 0.8232269
## [225] 0.8232269 0.8232269 0.8232269 0.8232269 0.8232269 0.8178198 0.8178198
## [232] 0.8178198 0.8178198 0.8178198 0.8178198 0.8178198 0.8178198 0.8178198
## [239] 0.8178198 0.8133098 0.8133098 0.8133098 0.8133098 0.8086711 0.8023902
## [246] 0.8023902 0.8023902 0.8023902 0.8023902 0.8023902 0.8023902 0.8023902
## [253] 0.8023902 0.8023902 0.8023902 0.8023902 0.7966588 0.7888865 0.7888865
## [260] 0.7830139 0.7830139 0.7830139 0.7789778 0.7789778 0.7707780 0.7707780
## [267] 0.7666341 0.7666341 0.7582555 0.7582555 0.7582555 0.7582555 0.7582555
## [274] 0.7582555 0.7582555 0.7582555 0.7582555 0.7582555 0.7582555 0.7582555
## [281] 0.7503018 0.7503018 0.7503018 0.7503018 0.7503018 0.7387141 0.7387141
## [288] 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141
## [295] 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141
## [302] 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141 0.7387141
## [309] 0.7387141 0.7387141 0.7387141 0.7387141 0.7158673 0.7158673 0.7158673
## [316] 0.7158673 0.7158673 0.7158673 0.7158673 0.7158673 0.7158673 0.7158673
## [323] 0.7158673 0.7158673 0.7158673 0.7158673 0.7158673 0.7158673 0.7158673
## [330] 0.7158673 0.7158673
## 
## $std.err
##   [1] 0.002038737 0.002886156 0.003538425 0.004090014 0.004577476 0.005019541
##   [7] 0.005427322 0.005808054 0.006831797 0.007143024 0.007442468 0.007731506
##  [13] 0.008011271 0.008803694 0.009054512 0.009539376 0.009774266 0.010230726
##  [19] 0.010671352 0.011098078 0.011306736 0.011512494 0.011915929 0.012113886
##  [25] 0.012309506 0.012502903 0.012883450 0.013256300 0.013622127 0.013981523
##  [31] 0.014335013 0.014509691 0.014855183 0.015026096 0.015195849 0.015532046
##  [37] 0.015864099 0.016028665 0.016355048 0.016677978 0.016838223 0.017156411
##  [43] 0.017628328 0.018094372 0.018402093 0.019011093 0.019462761 0.019910554
##  [49] 0.020354865 0.020796056 0.021234460 0.021670390 0.022104132 0.022535958
##  [55] 0.022966120 0.023537496 0.023964686 0.024390963 0.024674739 0.025099936
##  [61] 0.025383169 0.025807806 0.026090830 0.026373861 0.026798527 0.027507021
##  [67] 0.027790806 0.028217039 0.028644074 0.029072057 0.029501133 0.029931446
##  [73] 0.029931446 0.029931446 0.030443550 0.030443550 0.031006461 0.031006461
##  [79] 0.031006461 0.031615356 0.032243413 0.032243413 0.032243413 0.032243413
##  [85] 0.032739819 0.034066820 0.034066820 0.034066820 0.034066820 0.034066820
##  [91] 0.035248451 0.035248451 0.035248451 0.035248451 0.035592696 0.035592696
##  [97] 0.036339155 0.036339155 0.036339155 0.036339155 0.036339155 0.037247298
## [103] 0.038672811 0.038672811 0.038672811 0.038672811 0.038672811 0.038672811
## [109] 0.038672811 0.038672811 0.040672877 0.042663084 0.042663084 0.042663084
## [115] 0.042663084 0.044261013 0.044261013 0.044261013 0.047789033 0.047789033
## [121] 0.047789033 0.047789033 0.051115665 0.051115665 0.051115665 0.058349826
## [127] 0.058349826 0.058349826 0.058349826 0.058349826 0.058349826 0.065654393
## [133] 0.065654393 0.065654393 0.065654393 0.085678482 0.085678482 0.085678482
## [139] 0.085678482 0.085678482 0.085678482 0.085678482 0.085678482 0.001094691
## [145] 0.001548975 0.001898140 0.002192988 0.002453183 0.002688807 0.002688807
## [151] 0.003109055 0.003299779 0.003480454 0.003652947 0.003976577 0.004129390
## [157] 0.004277068 0.004420129 0.004694075 0.004954023 0.005202078 0.005439875
## [163] 0.005555342 0.005668711 0.005780105 0.005889638 0.006103520 0.006311081
## [169] 0.006512931 0.006709592 0.006901512 0.007089083 0.007272647 0.007452506
## [175] 0.007628927 0.007887627 0.008547324 0.008784932 0.009017894 0.009170805
## [181] 0.009321913 0.009471311 0.009692384 0.009765307 0.009910058 0.010126100
## [187] 0.010339146 0.010549393 0.010688092 0.010894066 0.011097688 0.011299102
## [193] 0.011498439 0.011630237 0.011826380 0.011956152 0.012277334 0.012467954
## [199] 0.012657114 0.012782448 0.012969349 0.013154992 0.013278090 0.013461789
## [205] 0.013583649 0.013765575 0.013946514 0.014006618 0.014126521 0.014424597
## [211] 0.014602360 0.014783132 0.014909185 0.014909185 0.014909185 0.014909185
## [217] 0.015118727 0.015118727 0.015192112 0.015192112 0.015418814 0.015418814
## [223] 0.015418814 0.015418814 0.015418814 0.015418814 0.015418814 0.015418814
## [229] 0.015418814 0.015766935 0.015766935 0.015766935 0.015766935 0.015766935
## [235] 0.015766935 0.015766935 0.015766935 0.015766935 0.015766935 0.016086945
## [241] 0.016086945 0.016086945 0.016086945 0.016422393 0.016878821 0.016878821
## [247] 0.016878821 0.016878821 0.016878821 0.016878821 0.016878821 0.016878821
## [253] 0.016878821 0.016878821 0.016878821 0.016878821 0.017378830 0.018056953
## [259] 0.018056953 0.018565128 0.018565128 0.018565128 0.018921362 0.018921362
## [265] 0.019647225 0.019647225 0.020013599 0.020013599 0.020754147 0.020754147
## [271] 0.020754147 0.020754147 0.020754147 0.020754147 0.020754147 0.020754147
## [277] 0.020754147 0.020754147 0.020754147 0.020754147 0.021628686 0.021628686
## [283] 0.021628686 0.021628686 0.021628686 0.022986187 0.022986187 0.022986187
## [289] 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187
## [295] 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187
## [301] 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187
## [307] 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187 0.022986187
## [313] 0.029281126 0.029281126 0.029281126 0.029281126 0.029281126 0.029281126
## [319] 0.029281126 0.029281126 0.029281126 0.029281126 0.029281126 0.029281126
## [325] 0.029281126 0.029281126 0.029281126 0.029281126 0.029281126 0.029281126
## [331] 0.029281126
## 
## $cumhaz
##   [1] 0.002036660 0.004077476 0.006122466 0.008171646 0.010225034 0.012282648
##   [7] 0.014344503 0.016410619 0.022621799 0.024705132 0.026792815 0.028884865
##  [13] 0.030981301 0.037283822 0.039397987 0.043635275 0.045762935 0.050027327
##  [19] 0.054309983 0.058611058 0.060770885 0.062935387 0.067273782 0.069452431
##  [25] 0.071635837 0.073824021 0.078209986 0.082615272 0.087040051 0.091484496
##  [31] 0.095948781 0.098190934 0.102685316 0.104942652 0.107205096 0.111740243
##  [37] 0.116296052 0.118584381 0.123171537 0.127779832 0.130094647 0.134735018
##  [43] 0.141728025 0.148770279 0.153498411 0.162999599 0.170193843 0.177440220
##  [49] 0.184739490 0.192092431 0.199499839 0.206962525 0.214481322 0.222057080
##  [55] 0.229690668 0.239947078 0.247719099 0.255551997 0.260815155 0.268751663
##  [61] 0.274084996 0.282127891 0.287533297 0.292968079 0.301164801 0.314938905
##  [67] 0.320525498 0.328952464 0.337451047 0.346022476 0.354668009 0.363388939
##  [73] 0.363388939 0.363388939 0.372973604 0.372973604 0.383108739 0.383108739
##  [79] 0.383108739 0.393747037 0.404656128 0.404656128 0.404656128 0.404656128
##  [85] 0.412656128 0.433489461 0.433489461 0.433489461 0.433489461 0.433489461
##  [91] 0.451426681 0.451426681 0.451426681 0.451426681 0.456352789 0.456352789
##  [97] 0.466662068 0.466662068 0.466662068 0.466662068 0.466662068 0.478156320
## [103] 0.496013463 0.496013463 0.496013463 0.496013463 0.496013463 0.496013463
## [109] 0.496013463 0.496013463 0.517596197 0.539655021 0.539655021 0.539655021
## [115] 0.539655021 0.556183946 0.556183946 0.556183946 0.591582176 0.591582176
## [121] 0.591582176 0.591582176 0.622510011 0.622510011 0.622510011 0.683485621
## [127] 0.683485621 0.683485621 0.683485621 0.683485621 0.683485621 0.725152288
## [133] 0.725152288 0.725152288 0.725152288 0.816061379 0.816061379 0.816061379
## [139] 0.816061379 0.816061379 0.816061379 0.816061379 0.816061379 0.001094092
## [145] 0.002189382 0.003285873 0.004383568 0.005482469 0.006582579 0.006582579
## [151] 0.008787651 0.009892623 0.010998818 0.012107466 0.014327221 0.015439568
## [157] 0.016553154 0.017667981 0.019900124 0.022137261 0.024379413 0.026626604
## [163] 0.027752730 0.028880126 0.030008794 0.031138738 0.033401181 0.035668755
## [169] 0.037941482 0.040219386 0.042502491 0.044790821 0.047084399 0.049383249
## [175] 0.051687397 0.055151600 0.064421589 0.067930361 0.071451487 0.073807200
## [181] 0.076168475 0.078535339 0.082094058 0.083284534 0.085668324 0.089265446
## [187] 0.092875555 0.096498743 0.098922986 0.102568186 0.106226723 0.109898693
## [193] 0.113584197 0.116050288 0.119758570 0.122239960 0.128458865 0.132213558
## [199] 0.135982403 0.138504471 0.142297138 0.146104245 0.148652016 0.152483433
## [205] 0.155047536 0.158903577 0.162774545 0.164069881 0.166663915 0.173165866
## [211] 0.177092567 0.181076631 0.183808872 0.183808872 0.183808872 0.183808872
## [217] 0.188144132 0.188144132 0.189634445 0.189634445 0.194186797 0.194186797
## [223] 0.194186797 0.194186797 0.194186797 0.194186797 0.194186797 0.194186797
## [229] 0.194186797 0.200754941 0.200754941 0.200754941 0.200754941 0.200754941
## [235] 0.200754941 0.200754941 0.200754941 0.200754941 0.200754941 0.206269647
## [241] 0.206269647 0.206269647 0.206269647 0.211973069 0.219740059 0.219740059
## [247] 0.219740059 0.219740059 0.219740059 0.219740059 0.219740059 0.219740059
## [253] 0.219740059 0.219740059 0.219740059 0.219740059 0.226882917 0.236639014
## [259] 0.236639014 0.244083183 0.244083183 0.244083183 0.249237822 0.249237822
## [265] 0.259764138 0.259764138 0.265140482 0.265140482 0.276069444 0.276069444
## [271] 0.276069444 0.276069444 0.276069444 0.276069444 0.276069444 0.276069444
## [277] 0.276069444 0.276069444 0.276069444 0.276069444 0.286558954 0.286558954
## [283] 0.286558954 0.286558954 0.286558954 0.302002970 0.302002970 0.302002970
## [289] 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970
## [295] 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970
## [301] 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970
## [307] 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970 0.302002970
## [313] 0.332930805 0.332930805 0.332930805 0.332930805 0.332930805 0.332930805
## [319] 0.332930805 0.332930805 0.332930805 0.332930805 0.332930805 0.332930805
## [325] 0.332930805 0.332930805 0.332930805 0.332930805 0.332930805 0.332930805
## [331] 0.332930805
## 
## $std.chaz
##   [1] 0.002036660 0.002883213 0.003534812 0.004085834 0.004572794 0.005014401
##   [7] 0.005421758 0.005802094 0.006820842 0.007131911 0.007431190 0.007720055
##  [13] 0.007999644 0.008788338 0.009039059 0.009522704 0.009757501 0.010212803
##  [19] 0.010652319 0.011077975 0.011286558 0.011492235 0.011894633 0.012092510
##  [25] 0.012288046 0.012481355 0.012860893 0.013232756 0.013597616 0.013956064
##  [31] 0.014308621 0.014483228 0.014827799 0.014998639 0.015168317 0.015503600
##  [37] 0.015834750 0.015999243 0.016324729 0.016646770 0.016806943 0.017124247
##  [43] 0.017593765 0.018057455 0.018364348 0.018968854 0.019418286 0.019863865
##  [49] 0.020305982 0.020744995 0.021181235 0.021615009 0.022046604 0.022476286
##  [55] 0.022904308 0.023471383 0.023896455 0.024320609 0.024603708 0.025026755
##  [61] 0.025309301 0.025731759 0.026014085 0.026296408 0.026718841 0.027419731
##  [67] 0.027702828 0.028126819 0.028551589 0.028977285 0.029404049 0.029832024
##  [73] 0.029832024 0.029832024 0.030340922 0.030340922 0.030900031 0.030900031
##  [79] 0.030900031 0.031504545 0.032127959 0.032127959 0.032127959 0.032127959
##  [85] 0.032622167 0.033926558 0.033926558 0.033926558 0.033926558 0.033926558
##  [91] 0.035091983 0.035091983 0.035091983 0.035091983 0.035436053 0.035436053
##  [97] 0.036178094 0.036178094 0.036178094 0.036178094 0.036178094 0.037079824
## [103] 0.038486438 0.038486438 0.038486438 0.038486438 0.038486438 0.038486438
## [109] 0.038486438 0.038486438 0.040453397 0.042410784 0.042410784 0.042410784
## [115] 0.042410784 0.043991787 0.043991787 0.043991787 0.047418730 0.047418730
## [121] 0.047418730 0.047418730 0.050669316 0.050669316 0.050669316 0.057541156
## [127] 0.057541156 0.057541156 0.057541156 0.057541156 0.057541156 0.064645496
## [133] 0.064645496 0.064645496 0.064645496 0.083269809 0.083269809 0.083269809
## [139] 0.083269809 0.083269809 0.083269809 0.083269809 0.083269809 0.001094092
## [145] 0.001548127 0.001897101 0.002191786 0.002451838 0.002687331 0.002687331
## [151] 0.003106915 0.003297557 0.003478153 0.003650569 0.003973702 0.004126454
## [157] 0.004274073 0.004417073 0.004690604 0.004950168 0.005197863 0.005435321
## [163] 0.005550755 0.005664088 0.005775447 0.005884944 0.006098515 0.006305778
## [169] 0.006507340 0.006703723 0.006895374 0.007082684 0.007265993 0.007445604
## [175] 0.007621782 0.007879835 0.008534248 0.008771386 0.009003888 0.009156674
## [181] 0.009307658 0.009456929 0.009677552 0.009750499 0.009895123 0.010110715
## [187] 0.010323316 0.010533123 0.010671699 0.010877239 0.011080431 0.011281419
## [193] 0.011480334 0.011612014 0.011807737 0.011937391 0.012257090 0.012447309
## [199] 0.012636068 0.012761294 0.012947796 0.013133041 0.013256030 0.013439330
## [205] 0.013561080 0.013742607 0.013923148 0.013983274 0.014103065 0.014399706
## [211] 0.014577077 0.014757442 0.014883369 0.014883369 0.014883369 0.014883369
## [217] 0.015092366 0.015092366 0.015165768 0.015165768 0.015391832 0.015391832
## [223] 0.015391832 0.015391832 0.015391832 0.015391832 0.015391832 0.015391832
## [229] 0.015391832 0.015738286 0.015738286 0.015738286 0.015738286 0.015738286
## [235] 0.015738286 0.015738286 0.015738286 0.015738286 0.015738286 0.016057116
## [241] 0.016057116 0.016057116 0.016057116 0.016391277 0.016845044 0.016845044
## [247] 0.016845044 0.016845044 0.016845044 0.016845044 0.016845044 0.016845044
## [253] 0.016845044 0.016845044 0.016845044 0.016845044 0.017342500 0.018015484
## [259] 0.018015484 0.018521057 0.018521057 0.018521057 0.018876300 0.018876300
## [265] 0.019596314 0.019596314 0.019961665 0.019961665 0.020696102 0.020696102
## [271] 0.020696102 0.020696102 0.020696102 0.020696102 0.020696102 0.020696102
## [277] 0.020696102 0.020696102 0.020696102 0.020696102 0.021563980 0.021563980
## [283] 0.021563980 0.021563980 0.021563980 0.022904904 0.022904904 0.022904904
## [289] 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904
## [295] 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904
## [301] 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904
## [307] 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904 0.022904904
## [313] 0.029042698 0.029042698 0.029042698 0.029042698 0.029042698 0.029042698
## [319] 0.029042698 0.029042698 0.029042698 0.029042698 0.029042698 0.029042698
## [325] 0.029042698 0.029042698 0.029042698 0.029042698 0.029042698 0.029042698
## [331] 0.029042698
## 
## $strata
##     get(cat)=failure get(cat)=intolerance 
##                  143                  188 
## 
## $type
## [1] "right"
## 
## $logse
## [1] TRUE
## 
## $conf.int
## [1] 0.95
## 
## $conf.type
## [1] "log"
## 
## $lower
##   [1] 0.9939836 0.9903089 0.9870211 0.9839342 0.9809761 0.9781098 0.9753133
##   [8] 0.9725721 0.9645939 0.9619973 0.9594257 0.9568763 0.9543469 0.9468603
##  [15] 0.9443942 0.9394992 0.9370688 0.9322384 0.9274446 0.9226836 0.9203143
##  [22] 0.9179520 0.9132472 0.9109040 0.9085667 0.9062351 0.9015876 0.8969602
##  [29] 0.8923513 0.8877597 0.8831844 0.8809025 0.8763498 0.8740787 0.8718110
##  [36] 0.8672856 0.8627727 0.8605208 0.8560257 0.8515417 0.8493038 0.8448357
##  [43] 0.8381521 0.8314898 0.8270594 0.8182241 0.8116188 0.8050307 0.7984589
##  [50] 0.7919028 0.7853618 0.7788351 0.7723224 0.7658230 0.7593366 0.7507073
##  [57] 0.7442494 0.7378031 0.7335118 0.7270841 0.7228050 0.7163951 0.7121275
##  [64] 0.7078645 0.7014782 0.6908560 0.6866144 0.6802598 0.6739143 0.6675777
##  [71] 0.6612498 0.6549305 0.6549305 0.6549305 0.6480024 0.6480024 0.6407276
##  [78] 0.6407276 0.6407276 0.6331552 0.6254777 0.6254777 0.6254777 0.6254777
##  [85] 0.6198705 0.6053799 0.6053799 0.6053799 0.6053799 0.6053799 0.5931458
##  [92] 0.5931458 0.5931458 0.5931458 0.5898258 0.5898258 0.5828917 0.5828917
##  [99] 0.5828917 0.5828917 0.5828917 0.5751671 0.5633202 0.5633202 0.5633202
## [106] 0.5633202 0.5633202 0.5633202 0.5633202 0.5633202 0.5490059 0.5348052
## [113] 0.5348052 0.5348052 0.5348052 0.5243208 0.5243208 0.5243208 0.5022756
## [120] 0.5022756 0.5022756 0.5022756 0.4835780 0.4835780 0.4835780 0.4476986
## [127] 0.4476986 0.4476986 0.4476986 0.4476986 0.4476986 0.4229457 0.4229457
## [134] 0.4229457 0.4229457 0.3696983 0.3696983 0.3696983 0.3696983 0.3696983
## [141] 0.3696983 0.3696983 0.3696983 0.9967650 0.9947871 0.9930165 0.9913534
## [148] 0.9897592 0.9882138 0.9882138 0.9852229 0.9837665 0.9823303 0.9809096
## [155] 0.9781116 0.9767310 0.9753610 0.9740005 0.9713047 0.9686381 0.9659965
## [162] 0.9633766 0.9620740 0.9607759 0.9594820 0.9581921 0.9556235 0.9530688
## [169] 0.9505266 0.9479959 0.9454758 0.9429655 0.9404644 0.9379717 0.9354869
## [176] 0.9317736 0.9219433 0.9182806 0.9146295 0.9122015 0.9097781 0.9073590
## [183] 0.9037383 0.9025334 0.9001266 0.8965090 0.8928996 0.8892979 0.8869009
## [190] 0.8833113 0.8797285 0.8761522 0.8725822 0.8702055 0.8666453 0.8642750
## [197] 0.8583596 0.8548173 0.8512800 0.8489244 0.8453950 0.8418701 0.8395226
## [204] 0.8360050 0.8336623 0.8301516 0.8266449 0.8254769 0.8231421 0.8173124
## [211] 0.8138195 0.8102900 0.8078765 0.8078765 0.8078765 0.8078765 0.8040439
## [218] 0.8040439 0.8027301 0.8027301 0.7987209 0.7987209 0.7987209 0.7987209
## [225] 0.7987209 0.7987209 0.7987209 0.7987209 0.7987209 0.7929335 0.7929335
## [232] 0.7929335 0.7929335 0.7929335 0.7929335 0.7929335 0.7929335 0.7929335
## [239] 0.7929335 0.7880663 0.7880663 0.7880663 0.7880663 0.7830566 0.7762799
## [246] 0.7762799 0.7762799 0.7762799 0.7762799 0.7762799 0.7762799 0.7762799
## [253] 0.7762799 0.7762799 0.7762799 0.7762799 0.7699801 0.7614553 0.7614553
## [260] 0.7550346 0.7550346 0.7550346 0.7506184 0.7506184 0.7416612 0.7416612
## [267] 0.7371443 0.7371443 0.7280306 0.7280306 0.7280306 0.7280306 0.7280306
## [274] 0.7280306 0.7280306 0.7280306 0.7280306 0.7280306 0.7280306 0.7280306
## [281] 0.7191602 0.7191602 0.7191602 0.7191602 0.7191602 0.7061721 0.7061721
## [288] 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721
## [295] 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721
## [302] 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721 0.7061721
## [309] 0.7061721 0.7061721 0.7061721 0.7061721 0.6759404 0.6759404 0.6759404
## [316] 0.6759404 0.6759404 0.6759404 0.6759404 0.6759404 0.6759404 0.6759404
## [323] 0.6759404 0.6759404 0.6759404 0.6759404 0.6759404 0.6759404 0.6759404
## [330] 0.6759404 0.6759404
## 
## $upper
##   [1] 1.0000000 1.0000000 1.0000000 0.9998363 0.9987370 0.9975459 0.9962851
##   [8] 0.9949688 0.9907749 0.9893140 0.9878283 0.9863203 0.9847924 0.9801067
##  [15] 0.9785155 0.9752957 0.9736687 0.9703844 0.9670634 0.9637096 0.9620215
##  [22] 0.9603264 0.9569165 0.9552023 0.9534822 0.9517565 0.9482891 0.9448018
##  [29] 0.9412960 0.9377728 0.9342333 0.9324578 0.9288958 0.9271095 0.9253197
##  [36] 0.9217304 0.9181285 0.9163231 0.9127034 0.9090726 0.9072532 0.9036065
##  [43] 0.8981179 0.8926081 0.8889237 0.8815295 0.8759626 0.8703786 0.8647783
##  [50] 0.8591622 0.8535311 0.8478856 0.8422262 0.8365535 0.8308678 0.8232675
##  [57] 0.8175533 0.8118274 0.8080040 0.8022595 0.7984239 0.7926617 0.7888145
##  [64] 0.7849628 0.7791769 0.7695123 0.7656391 0.7598215 0.7539949 0.7481594
##  [71] 0.7423152 0.7364624 0.7364624 0.7364624 0.7301361 0.7301361 0.7235339
##  [78] 0.7235339 0.7235339 0.7166916 0.7097462 0.7097462 0.7097462 0.7097462
##  [85] 0.7047536 0.6918684 0.6918684 0.6918684 0.6918684 0.6918684 0.6810336
##  [92] 0.6810336 0.6810336 0.6810336 0.6781361 0.6781361 0.6721277 0.6721277
##  [99] 0.6721277 0.6721277 0.6721277 0.6655857 0.6555292 0.6555292 0.6555292
## [106] 0.6555292 0.6555292 0.6555292 0.6555292 0.6555292 0.6439003 0.6321577
## [113] 0.6321577 0.6321577 0.6321577 0.6236590 0.6236590 0.6236590 0.6057568
## [120] 0.6057568 0.6057568 0.6057568 0.5908620 0.5908620 0.5908620 0.5627566
## [127] 0.5627566 0.5627566 0.5627566 0.5627566 0.5627566 0.5470851 0.5470851
## [134] 0.5470851 0.5470851 0.5172574 0.5172574 0.5172574 0.5172574 0.5172574
## [141] 0.5172574 0.5172574 0.5172574 1.0000000 1.0000000 1.0000000 0.9999122
## [148] 0.9993229 0.9986846 0.9986846 0.9973036 0.9965740 0.9958242 0.9950566
## [155] 0.9934777 0.9926699 0.9918515 0.9910236 0.9893426 0.9876323 0.9858971
## [162] 0.9841402 0.9832544 0.9823642 0.9814697 0.9805712 0.9787629 0.9769408
## [169] 0.9751062 0.9732601 0.9714033 0.9695368 0.9676612 0.9657771 0.9638850
## [176] 0.9610331 0.9533562 0.9504536 0.9475395 0.9455907 0.9436373 0.9416796
## [183] 0.9387351 0.9377515 0.9357816 0.9328104 0.9298310 0.9268439 0.9248484
## [190] 0.9218492 0.9188432 0.9158307 0.9128120 0.9107961 0.9077676 0.9057454
## [197] 0.9006794 0.8976330 0.8945815 0.8925446 0.8894852 0.8864213 0.8843763
## [204] 0.8813051 0.8792553 0.8761772 0.8730952 0.8720669 0.8700092 0.8648576
## [211] 0.8617617 0.8586326 0.8564982 0.8564982 0.8564982 0.8564982 0.8531353
## [218] 0.8531353 0.8519864 0.8519864 0.8484848 0.8484848 0.8484848 0.8484848
## [225] 0.8484848 0.8484848 0.8484848 0.8484848 0.8484848 0.8434871 0.8434871
## [232] 0.8434871 0.8434871 0.8434871 0.8434871 0.8434871 0.8434871 0.8434871
## [239] 0.8434871 0.8393618 0.8393618 0.8393618 0.8393618 0.8351235 0.8293787
## [246] 0.8293787 0.8293787 0.8293787 0.8293787 0.8293787 0.8293787 0.8293787
## [253] 0.8293787 0.8293787 0.8293787 0.8293787 0.8242620 0.8173059 0.8173059
## [260] 0.8120302 0.8120302 0.8120302 0.8084087 0.8084087 0.8010379 0.8010379
## [267] 0.7973036 0.7973036 0.7897353 0.7897353 0.7897353 0.7897353 0.7897353
## [274] 0.7897353 0.7897353 0.7897353 0.7897353 0.7897353 0.7897353 0.7897353
## [281] 0.7827920 0.7827920 0.7827920 0.7827920 0.7827920 0.7727558 0.7727558
## [288] 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558
## [295] 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558
## [302] 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558 0.7727558
## [309] 0.7727558 0.7727558 0.7727558 0.7727558 0.7581527 0.7581527 0.7581527
## [316] 0.7581527 0.7581527 0.7581527 0.7581527 0.7581527 0.7581527 0.7581527
## [323] 0.7581527 0.7581527 0.7581527 0.7581527 0.7581527 0.7581527 0.7581527
## [330] 0.7581527 0.7581527
## 
## $t0
## [1] 0
## 
## $call
## survfit(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survfit"

treatment:

The survival curves for ddC and ddI treatment groups are closer to each other, especially in the earlier time periods. However, the ddI group seems to have a slightly better survival probability as time progresses at the end of the study (leveled off at approximately 65% at time 18, and ddC leveled off at 58%), though ddC has a great start but it drops below ddI as time goes. The overlapping confidence intervals suggest that the survival difference between these two treatments may not be statistically significant.

sex:

The survival probability for females (red line) appears to be lower than that for males (blue line) throughout most of the observed period. The wider confidence intervals for females indicate higher uncertainty in the survival estimate for this group.

prev_infection:

The red line drops quicker than the blue line, indicating that individuals with previous opportunistic AIDS infection have a lower survival probability over time (level off at 45%) compared to those without infection (level off at 85%). The gap between the curves suggests a statistically significant difference, as the confidence intervals for the two groups rarely overlap (just the beginning). This implies that previous AIDS infection status has a notable impact on survival time.

azt:

Though it is not as significant as prev_infection for those who failed and intolerance of AZT therapy, we still can clearly see the difference, the intolerance group has high survival probability (leveled off at about 70%). The confidence interval overlap each other a bit at the beginning, but in the long run, after time 10, the difference is clearer and the survival rate of intolerance group is also more certain than failure group since its confidence interval is tighter than failure group.

Conclusion: azt and prev_infection are essential for variable selection. For both variables, the curves are far apart, and the confidence intervals rarely overlap, suggesting that a formal test like the log-rank test would likely find a statistically significant difference between these two groups.

2-sample log-rank test

Now we perform log-rank test to see if there is a difference in survival function among the defined groups. Since there 4 categorical variables (death excluded) and each variable has two levels (groups), the 2-sample log-rank test will be used.

for (cat in cat_vars[-1]) { # Exclude "death"
  # Create survival object and test Survival Curve Differences
  cat('++++++++++++++++++++++++++', cat, '++++++++++++++++++++++++++\n')
  sur_diff <- survdiff(Surv(time, death) ~ get(cat), data = df) 
  print(sur_diff)
  cat('\n')
}
## ++++++++++++++++++++++++++ treatment ++++++++++++++++++++++++++
## $n
## groups
## get(cat)=ddC get(cat)=ddI 
##          717          688 
## 
## $obs
## [1] 200 212
## 
## $exp
## [1] 213.4143 198.5857
## 
## $var
##          [,1]     [,2]
## [1,]  102.533 -102.533
## [2,] -102.533  102.533
## 
## $chisq
## [1] 1.75498
## 
## $pvalue
## [1] 0.1852519
## 
## $call
## survdiff(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survdiff"
## 
## ++++++++++++++++++++++++++ sex ++++++++++++++++++++++++++
## $n
## groups
## get(cat)=female   get(cat)=male 
##             117            1288 
## 
## $obs
## [1]  33 379
## 
## $exp
## [1]  32.50011 379.49989
## 
## $var
##           [,1]      [,2]
## [1,]  29.81933 -29.81933
## [2,] -29.81933  29.81933
## 
## $chisq
## [1] 0.008380003
## 
## $pvalue
## [1] 0.9270617
## 
## $call
## survdiff(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survdiff"
## 
## ++++++++++++++++++++++++++ prev_infection ++++++++++++++++++++++++++
## $n
## groups
##   get(cat)=AIDS get(cat)=noAIDS 
##             863             542 
## 
## $obs
## [1] 344  68
## 
## $exp
## [1] 232.1101 179.8899
## 
## $var
##           [,1]      [,2]
## [1,]  100.4276 -100.4276
## [2,] -100.4276  100.4276
## 
## $chisq
## [1] 124.6604
## 
## $pvalue
## [1] 6.039441e-29
## 
## $call
## survdiff(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survdiff"
## 
## ++++++++++++++++++++++++++ azt ++++++++++++++++++++++++++
## $n
## groups
##     get(cat)=failure get(cat)=intolerance 
##                  491                  914 
## 
## $obs
## [1] 206 206
## 
## $exp
## [1] 136.5249 275.4751
## 
## $var
##           [,1]      [,2]
## [1,]  90.91499 -90.91499
## [2,] -90.91499  90.91499
## 
## $chisq
## [1] 53.09121
## 
## $pvalue
## [1] 3.184142e-13
## 
## $call
## survdiff(formula = Surv(time, death) ~ get(cat), data = df)
## 
## attr(,"class")
## [1] "survdiff"

For both treatment and sex:

The p-values are well above the significance threshold 0.05, indicating that there’s no significant difference in survival. Thus, the survival functions for these groups (ddC vs. ddI and female vs. male) are statistically similar in the data, which aligns from the conclusion above.

For prev_infection and azt:

The small p-values (below 0.05) suggest that there is a statistically significant difference in survival between the groups. In other words, it provides evidence that the groups do not share identical survival functions. Again, aligns with the assumption above.

Statistical modelling and analysis

Train-test approach

When dealing with longitudinal data where each individual has multiple rows (representing repeated measurements over time), it’s essential to avoid splitting the same individual’s measurements across both the training and testing sets. Each individual should appear in only one of the sets to ensure that the test set is independent of the training set.

# get all subjects
subjects <- unique(df$subject)

# 80% train, 20% test
train_subjects <- createDataPartition(subjects, p = 0.8, list = FALSE)

# define train and test dataset without having duplicate individual
train_df <- df[df$subject %in% subjects[train_subjects], ]
test_df <- df[!df$subject %in% subjects[train_subjects], ]

# Check the number of subjects in train and test sets
cat("Number of distinct subjects in train set:", length(unique(train_df$subject)), "\n")
## Number of distinct subjects in train set: 375
cat("Number of distinct subjects in test set:", length(unique(test_df$subject)), "\n")
## Number of distinct subjects in test set: 92
# Verify no subject is in both train and test sets
cat("Subjects appear in both train and test dataset:", length(intersect(train_df$subject, test_df$subject)), "\n")
## Subjects appear in both train and test dataset: 0
# count status only once for each individual knowing that death status is consistent
count_death_status <- function(df){
  unique_subjects = unique(df$subject)
  total_death = 0
  total_censored = 0
  for (sub in unique_subjects){
    status = unique(df[df$subject == sub, ]$death)
    if (status == 0){  #censoring
      total_censored = total_censored + 1
    }
    else if (status == 1){ #death
      total_death = total_death + 1
    }
  }
  cat("Total death:", total_death, "\n")
  cat("Total censored:", total_censored, "\n")
  cat("\n")
  cat("Proportion of death:", (total_death/(total_death + total_censored)) * 100, "\n")
  cat("Proportion of censored:", (total_censored/(total_death + total_censored)) * 100, "\n")
}

cat("\n++++++++++++ Initial data ++++++++++++\n")
## 
## ++++++++++++ Initial data ++++++++++++
count_death_status(df)
## Total death: 188 
## Total censored: 279 
## 
## Proportion of death: 40.25696 
## Proportion of censored: 59.74304
cat("\n++++++++++++ Train data ++++++++++++\n")
## 
## ++++++++++++ Train data ++++++++++++
count_death_status(train_df)
## Total death: 157 
## Total censored: 218 
## 
## Proportion of death: 41.86667 
## Proportion of censored: 58.13333
cat("\n++++++++++++ Test data ++++++++++++\n")
## 
## ++++++++++++ Test data ++++++++++++
count_death_status(test_df)
## Total death: 31 
## Total censored: 61 
## 
## Proportion of death: 33.69565 
## Proportion of censored: 66.30435

Proportion of censored data are more or less the same for both train and test data compared to initial dataset. So there is a balance proportion between train and test dataset of censored and uncensored data.

Start-stop format

Data is already a long-format type. Time-varying covariate is \(cd4\). Others are static binary (time-independent). Since the model assumes proportional hazards, meaning the effect of each covariate is consistent over time, we will transform it to start-stop dataframe.

# define time-dependent and time-indepedent dataframes for time-merge
## time-independent does not have duplicate individual
df_time_ind <- train_df[!duplicated(train_df$subject), c("subject", "time", "death", "treatment", "sex", "prev_infection", "azt")]
df_time_dep <- train_df[, c("subject", "time_obs", "cd4")]

df_time_ind <- tmerge(df_time_ind, df_time_ind, id = subject, event = event(time, death))
df_start_stop <- tmerge(df_time_ind, df_time_dep, id = subject, cd4 = tdc(time_obs, cd4))

df_start_stop <- subset(df_start_stop, select = -c(time, death))
head(df_start_stop)
##   subject treatment    sex prev_infection         azt tstart tstop event
## 1       3       ddI female           AIDS intolerance      0  2.00     0
## 2       3       ddI female           AIDS intolerance      2  6.00     0
## 3       3       ddI female           AIDS intolerance      6 18.53     1
## 4       4       ddC   male           AIDS     failure      0  2.00     0
## 5       4       ddC   male           AIDS     failure      2  6.00     0
## 6       4       ddC   male           AIDS     failure      6 12.00     0
##        cd4
## 1 3.464102
## 2 3.605551
## 3 6.164414
## 4 3.872983
## 5 4.582576
## 6 2.645751

Methodology

Cox poroportional hazards model

Fit cox model only with variables that are statistically significant from above conclusion. Though we know they are \(prev_infection\) and \(cd4\), we will fit numerous model to achieve the best one based on AIC/BIC criterion by playing around with predictors based on the knowledge we have above.

cox_lin_cd4_prev <- coxph(formula = Surv(tstart, tstop, event) ~ cd4 + prev_infection, data = df_start_stop, x = TRUE)
cox_lin_cd4_prev_sex <- coxph(formula = Surv(tstart, tstop, event) ~ prev_infection + cd4 + sex, data = df_start_stop, x = TRUE)
cox_lin_cd4_prev_treat <- coxph(formula = Surv(tstart, tstop, event) ~ prev_infection + cd4 + treatment, data = df_start_stop, x = TRUE)
cox_lin_cd4_prev_sex_treat <- coxph(formula = Surv(tstart, tstop, event) ~ prev_infection + cd4 + sex + treatment, data = df_start_stop, x = TRUE)
cox_lin_full <- coxph(formula = Surv(tstart, tstop, event) ~ cd4 + prev_infection + azt + sex + treatment, data = df_start_stop, x = TRUE)
AIC(cox_lin_cd4_prev, cox_lin_cd4_prev_sex, cox_lin_cd4_prev_treat, cox_lin_cd4_prev_sex_treat, cox_lin_full)
##                            df      AIC
## cox_lin_cd4_prev            2 1641.798
## cox_lin_cd4_prev_sex        3 1641.477
## cox_lin_cd4_prev_treat      3 1640.829
## cox_lin_cd4_prev_sex_treat  4 1640.234
## cox_lin_full                5 1641.565
BIC(cox_lin_cd4_prev, cox_lin_cd4_prev_sex, cox_lin_cd4_prev_treat, cox_lin_cd4_prev_sex_treat, cox_lin_full)
##                            df      BIC
## cox_lin_cd4_prev            2 1647.910
## cox_lin_cd4_prev_sex        3 1650.646
## cox_lin_cd4_prev_treat      3 1649.998
## cox_lin_cd4_prev_sex_treat  4 1652.459
## cox_lin_full                5 1656.847

Though \(treatment\) does not show a strong predictive power in log-rank test, we will keep it for fitting since it is one the main research question and also the longitudinal study of the initial was to study the effectiveness of the two treatments as well. Model with \(treatment\) has predictor has the lowest AIC but BIC is slightly higher than those without.

Variable selection, step model

# Fit the initial Cox model with all covariates
cox_lin_full <- coxph(formula = Surv(tstart, tstop, event) ~ cd4 + prev_infection + azt + sex + treatment, data = df_start_stop, x = TRUE, id = subject)

# Perform stepwise selection using AIC
step_model <- stepAIC(cox_lin_full, direction = "both")  
## Start:  AIC=1641.57
## Surv(tstart, tstop, event) ~ cd4 + prev_infection + azt + sex + 
##     treatment
## 
##                  Df    AIC
## - azt             1 1640.2
## <none>              1641.6
## - sex             1 1642.3
## - treatment       1 1642.8
## - prev_infection  1 1652.2
## - cd4             1 1687.6
## 
## Step:  AIC=1640.23
## Surv(tstart, tstop, event) ~ cd4 + prev_infection + sex + treatment
## 
##                  Df    AIC
## <none>              1640.2
## - sex             1 1640.8
## - treatment       1 1641.5
## + azt             1 1641.6
## - prev_infection  1 1657.8
## - cd4             1 1686.8
# View the selected model
summary(step_model)
## Call:
## coxph(formula = Surv(tstart, tstop, event) ~ cd4 + prev_infection + 
##     sex + treatment, data = df_start_stop, x = TRUE, id = subject)
## 
##   n= 1127, number of events= 157 
## 
##                          coef exp(coef) se(coef)      z Pr(>|z|)    
## cd4                  -0.17659   0.83812  0.02891 -6.109 1.00e-09 ***
## prev_infectionnoAIDS -0.97389   0.37761  0.24318 -4.005 6.21e-05 ***
## sexmale              -0.43938   0.64444  0.25783 -1.704   0.0884 .  
## treatmentddI          0.28926   1.33543  0.16069  1.800   0.0718 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                      exp(coef) exp(-coef) lower .95 upper .95
## cd4                     0.8381     1.1931    0.7920    0.8870
## prev_infectionnoAIDS    0.3776     2.6482    0.2344    0.6082
## sexmale                 0.6444     1.5517    0.3888    1.0682
## treatmentddI            1.3354     0.7488    0.9746    1.8298
## 
## Concordance= 0.735  (se = 0.018 )
## Likelihood ratio test= 111.1  on 4 df,   p=<2e-16
## Wald test            = 72.27  on 4 df,   p=8e-15
## Score (logrank) test = 85.36  on 4 df,   p=<2e-16
autoplot(survfit(step_model))

Stepwise algorithm indicates that azt does not contribute meaningful predictive power based on this dataset. sex and treatment are close to 0.05. cd4 and prev_infectionnoAIDS are statistically significant at the 0.05 level.

The hazard ratio for cd4 (0.83812) indicates that for each unit increase in cd4, the hazard of the event decreases by about 16.2% (1 - 0.83812). The hazard ratio for prev_infectionnoAIDS (0.37761) indicates that patients with no prior AIDS infection have a much lower hazard (reduced by 62.2% compared to those with AIDS)

Concordance = 0.735: This suggests that the model has reasonable discriminatory power, meaning the model can correctly order pairs of individuals 73.5% of the time based on their risk of the event. Also, the likelihood ratio test, Wald test, and score test all have highly significant p-values, suggesting that the overall model is statistically significant.

brier_results <- Score(
  object = list(cox = step_model),  # Model to evaluate
  formula = Surv(time, death) ~ 1,  # Survival formula (specify the time and event variables)
  data = test_df,  # Test data for evaluation
  metrics = "brier",  # Calculate Brier score
  cens.model = "km",
  times=sort(unique(test_df$time)) # Sequence of times to evaluate Brier score
)
print(brier_results)
## $Brier
## 
## Results by model:
## 
##           model times  Brier  lower  upper
##          <fctr> <num> <char> <char> <char>
##   1: Null model  2.17  0.000  0.000  0.000
##   2: Null model  2.40  0.360  0.000  1.062
##   3: Null model  2.60  0.717  0.000  1.701
##   4: Null model  2.73  1.071  0.000  2.266
##   5: Null model  3.40  1.772  0.259  3.286
##  ---                                      
## 156:        cox 19.03 25.034 18.429 31.639
## 157:        cox 19.57 22.768 14.700 30.837
## 158:        cox 20.27 30.107 21.377 38.836
## 159:        cox 20.87 35.363 27.246 43.480
## 160:        cox 21.13  7.930  5.681 10.179
## 
## Results of model comparisons:
## 
##     times  model  reference delta.Brier  lower  upper            p
##     <num> <fctr>     <fctr>      <char> <char> <char>        <num>
##  1:  2.17    cox Null model       0.352  0.299  0.404 5.232716e-39
##  2:  2.40    cox Null model       0.327  0.256  0.398 1.253356e-19
##  3:  2.60    cox Null model       0.422  0.268  0.577 8.855669e-08
##  4:  2.73    cox Null model       0.345  0.080  0.610 1.069766e-02
##  5:  3.40    cox Null model       0.409 -0.096  0.913 1.127190e-01
##  6:  4.20    cox Null model       0.767  0.157  1.378 1.370604e-02
##  7:  4.67    cox Null model       1.044  0.357  1.732 2.908353e-03
##  8:  5.23    cox Null model       1.153  0.339  1.966 5.481655e-03
##  9:  6.13    cox Null model       1.804  0.846  2.761 2.239063e-04
## 10:  6.30    cox Null model       1.717  0.776  2.659 3.509564e-04
## 11:  6.60    cox Null model       1.330  0.313  2.347 1.039013e-02
## 12:  7.17    cox Null model       1.619  0.481  2.757 5.312021e-03
## 13:  7.83    cox Null model       2.139  0.890  3.387 7.892294e-04
## 14:  7.93    cox Null model       2.039  0.811  3.266 1.130720e-03
## 15:  8.80    cox Null model       2.739  1.245  4.232 3.257149e-04
## 16: 10.23    cox Null model       3.829  1.930  5.728 7.751411e-05
## 17: 11.07    cox Null model       5.406  3.178  7.635 1.984464e-06
## 18: 11.20    cox Null model       4.808  2.485  7.131 4.970148e-05
## 19: 11.50    cox Null model       4.448  1.994  6.903 3.827716e-04
## 20: 11.67    cox Null model       3.950  1.400  6.501 2.402139e-03
## 21: 11.90    cox Null model       3.751  1.228  6.274 3.567421e-03
## 22: 11.93    cox Null model       3.921  1.413  6.429 2.179991e-03
## 23: 12.20    cox Null model       4.023  1.439  6.607 2.275633e-03
## 24: 12.23    cox Null model       3.906  1.300  6.513 3.306564e-03
## 25: 12.27    cox Null model       3.468  0.825  6.111 1.012844e-02
## 26: 12.30    cox Null model       3.870  1.171  6.569 4.950185e-03
## 27: 12.33    cox Null model       3.564  0.873  6.255 9.447102e-03
## 28: 12.43    cox Null model       3.877  1.137  6.617 5.555120e-03
## 29: 12.50    cox Null model       4.174  1.382  6.965 3.383392e-03
## 30: 12.63    cox Null model       3.199  0.367  6.032 2.684311e-02
## 31: 12.67    cox Null model       2.767 -0.002  5.536 5.020011e-02
## 32: 12.70    cox Null model       2.725 -0.082  5.532 5.703667e-02
## 33: 13.00    cox Null model       2.781 -0.032  5.594 5.268092e-02
## 34: 13.03    cox Null model       2.319 -0.472  5.111 1.034164e-01
## 35: 13.20    cox Null model       2.282 -0.585  5.149 1.187309e-01
## 36: 13.27    cox Null model       2.339 -0.552  5.229 1.127530e-01
## 37: 13.37    cox Null model       2.665 -0.312  5.641 7.933203e-02
## 38: 13.43    cox Null model       2.935 -0.071  5.942 5.567481e-02
## 39: 13.50    cox Null model       3.090  0.036  6.144 4.736233e-02
## 40: 13.60    cox Null model       3.519  0.393  6.645 2.736281e-02
## 41: 13.70    cox Null model       3.399  0.243  6.554 3.478182e-02
## 42: 13.73    cox Null model       3.147 -0.028  6.323 5.203919e-02
## 43: 13.87    cox Null model       3.588  0.331  6.844 3.081420e-02
## 44: 13.90    cox Null model       3.838  0.494  7.183 2.447699e-02
## 45: 14.17    cox Null model       3.946  0.523  7.370 2.387021e-02
## 46: 14.33    cox Null model       3.814  0.369  7.258 2.998976e-02
## 47: 14.40    cox Null model       2.862 -0.583  6.306 1.034612e-01
## 48: 14.43    cox Null model       3.261 -0.276  6.798 7.073057e-02
## 49: 14.57    cox Null model       3.571 -0.034  7.176 5.221766e-02
## 50: 14.63    cox Null model       4.187  0.468  7.907 2.734128e-02
## 51: 15.03    cox Null model       4.516  0.616  8.417 2.323651e-02
## 52: 15.10    cox Null model       4.107  0.166  8.048 4.111800e-02
## 53: 15.17    cox Null model       3.551 -0.266  7.368 6.827137e-02
## 54: 15.27    cox Null model       4.118  0.214  8.021 3.867472e-02
## 55: 15.33    cox Null model       2.544 -1.329  6.418 1.979709e-01
## 56: 15.53    cox Null model       1.072 -2.562  4.706 5.632565e-01
## 57: 15.57    cox Null model       0.301 -3.285  3.886 8.694928e-01
## 58: 15.77    cox Null model       0.498 -3.203  4.198 7.921317e-01
## 59: 15.90    cox Null model       0.987 -2.814  4.787 6.108142e-01
## 60: 15.97    cox Null model       0.973 -2.879  4.826 6.204427e-01
## 61: 16.03    cox Null model       1.269 -2.677  5.215 5.285400e-01
## 62: 16.20    cox Null model       1.790 -2.239  5.819 3.839103e-01
## 63: 16.23    cox Null model       2.282 -1.841  6.405 2.779837e-01
## 64: 16.43    cox Null model       3.177 -1.272  7.625 1.616005e-01
## 65: 16.97    cox Null model       2.501 -2.128  7.130 2.896670e-01
## 66: 17.03    cox Null model       1.896 -2.641  6.433 4.128057e-01
## 67: 17.20    cox Null model       0.059 -4.048  4.166 9.775127e-01
## 68: 17.40    cox Null model       0.717 -3.578  5.011 7.436397e-01
## 69: 17.57    cox Null model       1.709 -2.771  6.189 4.546096e-01
## 70: 17.80    cox Null model       2.884 -1.999  7.767 2.469630e-01
## 71: 17.83    cox Null model       2.219 -2.817  7.256 3.877569e-01
## 72: 18.07    cox Null model      -3.844 -8.330  0.643 9.312918e-02
## 73: 18.13    cox Null model      -2.584 -7.391  2.224 2.921692e-01
## 74: 18.57    cox Null model      -3.195 -8.414  2.023 2.300625e-01
## 75: 19.00    cox Null model      -1.602 -7.738  4.535 6.089665e-01
## 76: 19.03    cox Null model       1.159 -6.002  8.320 7.510114e-01
## 77: 19.57    cox Null model      -1.106 -9.519  7.306 7.965768e-01
## 78: 20.27    cox Null model       6.232 -2.666 15.129 1.698235e-01
## 79: 20.87    cox Null model      11.488  3.422 19.553 5.243993e-03
## 80: 21.13    cox Null model      -6.540 -9.250 -3.830 2.244476e-06
##     times  model  reference delta.Brier  lower  upper            p
## 
## NOTE: Values are multiplied by 100 and given in %.
## NOTE: The lower Brier the better.
## 
## $response.type
## [1] "survival"
## 
## $dolist
## $dolist[[1]]
## [1] 0 1
## 
## 
## $cause
## [1] "1"
## 
## $states
## [1] "1"
## 
## $null.model
## [1] "Null model"
## 
## $models
## Null model        cox 
##          0          1 
## 
## $cens.type
## [1] "rightCensored"
## 
## $censoringHandling
## [1] "ipcw"
## 
## $split.method
## $name
## [1] "no data splitting"
## 
## $internal.name
## [1] "noplan"
## 
## $index
## [1] "split index was not saved"
## 
## $k
## NULL
## 
## $B
## [1] 0
## 
## $M
## [1] 278
## 
## $N
## [1] 278
## 
## attr(,"class")
## [1] "split.method"
## 
## $metrics
## [1] "Brier"
## 
## $times
##  [1]  2.17  2.40  2.60  2.73  3.40  4.20  4.67  5.23  6.13  6.30  6.60  7.17
## [13]  7.83  7.93  8.80 10.23 11.07 11.20 11.50 11.67 11.90 11.93 12.20 12.23
## [25] 12.27 12.30 12.33 12.43 12.50 12.63 12.67 12.70 13.00 13.03 13.20 13.27
## [37] 13.37 13.43 13.50 13.60 13.70 13.73 13.87 13.90 14.17 14.33 14.40 14.43
## [49] 14.57 14.63 15.03 15.10 15.17 15.27 15.33 15.53 15.57 15.77 15.90 15.97
## [61] 16.03 16.20 16.23 16.43 16.97 17.03 17.20 17.40 17.57 17.80 17.83 18.07
## [73] 18.13 18.57 19.00 19.03 19.57 20.27 20.87 21.13
## 
## $alpha
## [1] 0.05
## 
## $plots
## character(0)
## 
## $summary
## character(0)
## 
## $missing.predictions
## [1] "None"
## 
## $off.predictions
## [1] "None"
## 
## $call
## Score.list(object = list(cox = step_model), formula = Surv(time, 
##     death) ~ 1, data = test_df, metrics = "brier", times = sort(unique(test_df$time)), 
##     cens.model = "km")
## 
## attr(,"class")
## [1] "Score"
print(brier_results$Brier$score)
##          model times       Brier          se        lower       upper
## 1   Null model  2.17 0.000000000 0.000000000 0.0000000000 0.000000000
## 2   Null model  2.40 0.003597075 0.003584019 0.0000000000 0.010621624
## 3   Null model  2.60 0.007168085 0.005022583 0.0000000000 0.017012166
## 4   Null model  2.73 0.010713029 0.006095205 0.0000000000 0.022659411
## 5   Null model  3.40 0.017724719 0.007724383 0.0025852067 0.032864232
## 6   Null model  4.20 0.021191466 0.008382803 0.0047614750 0.037621457
## 7   Null model  4.67 0.024632147 0.008969531 0.0070521889 0.042212105
## 8   Null model  5.23 0.031435311 0.009978643 0.0118775294 0.050993093
## 9   Null model  6.13 0.038134213 0.010820826 0.0169257824 0.059342643
## 10  Null model  6.30 0.044728851 0.011535341 0.0221199972 0.067337705
## 11  Null model  6.60 0.051219226 0.012147204 0.0274111440 0.075027308
## 12  Null model  7.17 0.060759296 0.012908812 0.0354584895 0.086060102
## 13  Null model  7.83 0.063887187 0.013127065 0.0381586121 0.089615763
## 14  Null model  7.93 0.070064773 0.013517008 0.0435719238 0.096557623
## 15  Null model  8.80 0.079135659 0.013998595 0.0516989168 0.106572402
## 16  Null model 10.23 0.093732487 0.014569748 0.0651763053 0.122288669
## 17  Null model 11.07 0.102177795 0.014795196 0.0731797430 0.131175846
## 18  Null model 11.20 0.110388510 0.014944973 0.0810969008 0.139680120
## 19  Null model 11.50 0.118364634 0.015026917 0.0889124171 0.147816851
## 20  Null model 11.67 0.126106166 0.015047544 0.0966135207 0.155598811
## 21  Null model 11.90 0.131136858 0.015029987 0.1016786242 0.160595092
## 22  Null model 11.93 0.136063288 0.014989079 0.1066852326 0.165441343
## 23  Null model 12.20 0.136063288 0.014989079 0.1066852319 0.165441343
## 24  Null model 12.23 0.136063288 0.014989080 0.1066852311 0.165441344
## 25  Null model 12.27 0.141055746 0.014936375 0.1117809880 0.170330504
## 26  Null model 12.30 0.141055746 0.014936377 0.1117809841 0.170330508
## 27  Null model 12.33 0.141055746 0.014936378 0.1117809828 0.170330509
## 28  Null model 12.43 0.141055746 0.014936379 0.1117809814 0.170330510
## 29  Null model 12.50 0.141055746 0.014936380 0.1117809799 0.170330512
## 30  Null model 12.63 0.149240462 0.014876078 0.1200838852 0.178397038
## 31  Null model 12.67 0.157105607 0.014739873 0.1282159868 0.185995227
## 32  Null model 12.70 0.157105607 0.014739874 0.1282159854 0.185995228
## 33  Null model 13.00 0.157105607 0.014739874 0.1282159854 0.185995228
## 34  Null model 13.03 0.157105607 0.014739884 0.1282159658 0.185995248
## 35  Null model 13.20 0.157105607 0.014739886 0.1282159617 0.185995252
## 36  Null model 13.27 0.157105607 0.014739887 0.1282159597 0.185995254
## 37  Null model 13.37 0.157105607 0.014739887 0.1282159591 0.185995255
## 38  Null model 13.43 0.157105607 0.014739890 0.1282159540 0.185995260
## 39  Null model 13.50 0.157105607 0.014739906 0.1282159229 0.185995291
## 40  Null model 13.60 0.157105607 0.014739909 0.1282159161 0.185995298
## 41  Null model 13.70 0.157105607 0.014739913 0.1282159086 0.185995305
## 42  Null model 13.73 0.157105607 0.014739917 0.1282159002 0.185995314
## 43  Null model 13.87 0.157105607 0.014739922 0.1282158908 0.185995323
## 44  Null model 13.90 0.157105607 0.014739927 0.1282158804 0.185995333
## 45  Null model 14.17 0.157105607 0.014739933 0.1282158686 0.185995345
## 46  Null model 14.33 0.157105607 0.014739940 0.1282158554 0.185995358
## 47  Null model 14.40 0.157105607 0.014740160 0.1282154236 0.185995790
## 48  Null model 14.43 0.157105607 0.014740165 0.1282154143 0.185995800
## 49  Null model 14.57 0.157105607 0.014740178 0.1282153897 0.185995824
## 50  Null model 14.63 0.157105607 0.014740192 0.1282153612 0.185995853
## 51  Null model 15.03 0.157105607 0.014740209 0.1282153281 0.185995886
## 52  Null model 15.10 0.166475705 0.015122034 0.1368370629 0.196114347
## 53  Null model 15.17 0.183721828 0.015192498 0.1539450788 0.213498578
## 54  Null model 15.27 0.183721828 0.015192550 0.1539449777 0.213498679
## 55  Null model 15.33 0.191928993 0.014981685 0.1625654289 0.221292557
## 56  Null model 15.53 0.191928993 0.014981770 0.1625652633 0.221292722
## 57  Null model 15.57 0.199937194 0.014620562 0.1712814186 0.228592970
## 58  Null model 15.77 0.199937194 0.014620580 0.1712813848 0.228593004
## 59  Null model 15.90 0.199937194 0.014620736 0.1712810794 0.228593310
## 60  Null model 15.97 0.199937194 0.014620759 0.1712810339 0.228593355
## 61  Null model 16.03 0.199937194 0.014620847 0.1712808610 0.228593528
## 62  Null model 16.20 0.199937194 0.014620951 0.1712806575 0.228593731
## 63  Null model 16.23 0.199937194 0.014621074 0.1712804164 0.228593973
## 64  Null model 16.43 0.199937194 0.014621427 0.1712797233 0.228594666
## 65  Null model 16.97 0.199937194 0.014623992 0.1712746971 0.228599692
## 66  Null model 17.03 0.210835955 0.014365433 0.1826802232 0.238991687
## 67  Null model 17.20 0.210835955 0.014365910 0.1826792894 0.238992621
## 68  Null model 17.40 0.210835955 0.014366084 0.1826789476 0.238992963
## 69  Null model 17.57 0.210835955 0.014367797 0.1826755903 0.238996320
## 70  Null model 17.80 0.210835955 0.014370224 0.1826708336 0.239001077
## 71  Null model 17.83 0.210835955 0.014371685 0.1826679712 0.239003939
## 72  Null model 18.07 0.238749102 0.010602005 0.2179695533 0.259528650
## 73  Null model 18.13 0.238749102 0.010627685 0.2179192228 0.259578981
## 74  Null model 18.57 0.238749102 0.010645453 0.2178843972 0.259613806
## 75  Null model 19.00 0.238749102 0.010714244 0.2177495704 0.259748633
## 76  Null model 19.03 0.238749102 0.010996603 0.2171961560 0.260302048
## 77  Null model 19.57 0.238749102 0.011821480 0.2155794277 0.261918776
## 78  Null model 20.27 0.238749102 0.013447917 0.2123916683 0.265106535
## 79  Null model 20.87 0.238749102 0.014281622 0.2107576373 0.266740566
## 80  Null model 21.13 0.144698728 0.018230056 0.1089684744 0.180428982
## 81         cox  2.17 0.003516533 0.000269161 0.0029889870 0.004044079
## 82         cox  2.40 0.006868157 0.003354312 0.0002938267 0.013442487
## 83         cox  2.60 0.011391409 0.004409750 0.0027484568 0.020034361
## 84         cox  2.73 0.014161631 0.005004620 0.0043527563 0.023970506
## 85         cox  3.40 0.021809836 0.005543734 0.0109443181 0.032675354
## 86         cox  4.20 0.028865500 0.006174511 0.0167636818 0.040967318
## 87         cox  4.67 0.035074881 0.006662916 0.0220158053 0.048133957
## 88         cox  5.23 0.042960598 0.007160298 0.0289266724 0.056994524
## 89         cox  6.13 0.056169410 0.007999972 0.0404897536 0.071849066
## 90         cox  6.30 0.061903669 0.008859307 0.0445397461 0.079267593
## 91         cox  6.60 0.064515151 0.009094022 0.0466911953 0.082339107
## 92         cox  7.17 0.076946506 0.009608766 0.0581136714 0.095779340
## 93         cox  7.83 0.085272989 0.009878304 0.0659118691 0.104634109
## 94         cox  7.93 0.090452799 0.010416673 0.0700364948 0.110869103
## 95         cox  8.80 0.106520793 0.010358871 0.0862177791 0.126823806
## 96         cox 10.23 0.132021375 0.010659829 0.1111284936 0.152914256
## 97         cox 11.07 0.156242087 0.011039462 0.1346051387 0.177879036
## 98         cox 11.20 0.158472081 0.011038067 0.1368378677 0.180106293
## 99         cox 11.50 0.162846805 0.011051077 0.1411870925 0.184506518
## 100        cox 11.67 0.165607475 0.011061866 0.1439266164 0.187288334
## 101        cox 11.90 0.168646045 0.011212594 0.1466697640 0.190622326
## 102        cox 11.93 0.175275357 0.011617263 0.1525059401 0.198044773
## 103        cox 12.20 0.176295266 0.011715348 0.1533336058 0.199256927
## 104        cox 12.23 0.175127932 0.011783110 0.1520334616 0.198222402
## 105        cox 12.27 0.175731010 0.011903132 0.1524012989 0.199060720
## 106        cox 12.30 0.179754528 0.011984477 0.1562653849 0.203243672
## 107        cox 12.33 0.176693521 0.012043069 0.1530895400 0.200297502
## 108        cox 12.43 0.179821711 0.012115617 0.1560755385 0.203567883
## 109        cox 12.50 0.182791839 0.012212533 0.1588557147 0.206727963
## 110        cox 12.63 0.181232516 0.012158560 0.1574021756 0.205062857
## 111        cox 12.67 0.184772580 0.012463743 0.1603440923 0.209201068
## 112        cox 12.70 0.184360111 0.012578648 0.1597064129 0.209013809
## 113        cox 13.00 0.184915674 0.012595200 0.1602295365 0.209601811
## 114        cox 13.03 0.180299638 0.012632097 0.1555411833 0.205058092
## 115        cox 13.20 0.179928178 0.012825502 0.1547906570 0.205065699
## 116        cox 13.27 0.180492313 0.012940104 0.1551301748 0.205854451
## 117        cox 13.37 0.183752034 0.013081048 0.1581136516 0.209390416
## 118        cox 13.43 0.186460558 0.013167998 0.1606517571 0.212269360
## 119        cox 13.50 0.188003687 0.013396726 0.1617465876 0.214260787
## 120        cox 13.60 0.192297709 0.013559760 0.1657210680 0.218874351
## 121        cox 13.70 0.191090985 0.013774086 0.1640942735 0.218087697
## 122        cox 13.73 0.188579999 0.013971417 0.1611965246 0.215963474
## 123        cox 13.87 0.192981711 0.014191482 0.1651669175 0.220796505
## 124        cox 13.90 0.195490547 0.014521919 0.1670281088 0.223952985
## 125        cox 14.17 0.196569745 0.014842957 0.1674780833 0.225661407
## 126        cox 14.33 0.195241649 0.015004956 0.1658324754 0.224650822
## 127        cox 14.40 0.185722512 0.015288193 0.1557582037 0.215686819
## 128        cox 14.43 0.189715630 0.015593714 0.1591525122 0.220278747
## 129        cox 14.57 0.192815653 0.015911388 0.1616299064 0.224001400
## 130        cox 14.63 0.198978429 0.016298269 0.1670344084 0.230922450
## 131        cox 15.03 0.202268442 0.017060598 0.1688302842 0.235706599
## 132        cox 15.10 0.207544786 0.017361587 0.1735167016 0.241572871
## 133        cox 15.17 0.219231311 0.017858659 0.1842289837 0.254233639
## 134        cox 15.27 0.224897415 0.018151736 0.1893206671 0.260474163
## 135        cox 15.33 0.217373341 0.017683594 0.1827141329 0.252032549
## 136        cox 15.53 0.202646571 0.016686189 0.1699422409 0.235350901
## 137        cox 15.57 0.202942796 0.016698809 0.1702137328 0.235671860
## 138        cox 15.77 0.204912645 0.017068333 0.1714593268 0.238365963
## 139        cox 15.90 0.209805604 0.017449644 0.1756049313 0.244006278
## 140        cox 15.97 0.209670997 0.017747827 0.1748858951 0.244456099
## 141        cox 16.03 0.212626904 0.018170683 0.1770130198 0.248240788
## 142        cox 16.20 0.217835335 0.018451057 0.1816719284 0.253998741
## 143        cox 16.23 0.222758562 0.018813550 0.1858846809 0.259632443
## 144        cox 16.43 0.231705229 0.019974363 0.1925561970 0.270854260
## 145        cox 16.97 0.224947400 0.020848675 0.1840847487 0.265810052
## 146        cox 17.03 0.229794968 0.021019794 0.1885969294 0.270993007
## 147        cox 17.20 0.211426662 0.019298001 0.1736032762 0.249250048
## 148        cox 17.40 0.218002016 0.019826222 0.1791433352 0.256860697
## 149        cox 17.57 0.227926491 0.020512428 0.1877228717 0.268130110
## 150        cox 17.80 0.239679997 0.022106927 0.1963512167 0.283008778
## 151        cox 17.83 0.233029398 0.023201532 0.1875552303 0.278503566
## 152        cox 18.07 0.200312248 0.020811284 0.1595228815 0.241101615
## 153        cox 18.13 0.212910889 0.022140177 0.1695169389 0.256304839
## 154        cox 18.57 0.206795250 0.024203257 0.1593577380 0.254232762
## 155        cox 19.00 0.222733593 0.028476325 0.1669210210 0.278546165
## 156        cox 19.03 0.250342545 0.033698501 0.1842946956 0.316390394
## 157        cox 19.57 0.227684581 0.041164501 0.1470036406 0.308365520
## 158        cox 20.27 0.301065750 0.044537488 0.2137738765 0.388357623
## 159        cox 20.87 0.353628728 0.041415742 0.2724553640 0.434802091
## 160        cox 21.13 0.079299688 0.011474599 0.0568098877 0.101789489
plotBrier(brier_results)

Beyond linearity

Martingale residual works only for continuous covariate, so we refit with cd4 to see the effect.

ggcoxfunctional(formula = Surv(tstart, tstop, event) ~ cd4, 
                data = df_start_stop, 
                xvar = "cd4",
                title = "Martingale Residuals for CD4",
                ggtheme = theme_gray())
## Warning: arguments formula is deprecated; will be removed in the next version;
## please use fit instead.

There is no visible systematic pattern or curve, it supports the notion that \(cd4\) could be adequately modeled with a linear term in the Cox model.

cox.zph(step_model)
##                   chisq df    p
## cd4            0.470965  1 0.49
## prev_infection 0.081914  1 0.77
## sex            0.617467  1 0.43
## treatment      0.000607  1 0.98
## GLOBAL         1.341755  4 0.85
plot(cox.zph(step_model))

ggcoxzph(cox.zph(step_model))

The global test p-value for the Schoenfeld residuals is above the level of 0.05. This suggests that, globally, there is no strong evidence to reject the proportional hazards assumption for the model that covariates have constant coefficient. So, linear cox model is enough for this dataset.

ggcoxdiagnostics(step_model, type = "dfbeta",
                 linear.predictions = FALSE, ggtheme = theme_bw())
## `geom_smooth()` using formula = 'y ~ x'

ggcoxdiagnostics(step_model, type = "deviance",
                 linear.predictions = FALSE, ggtheme = theme_bw())
## `geom_smooth()` using formula = 'y ~ x'

Non-linear cox proportional hazards model

step_model_nonlin <- coxph(formula = Surv(tstart, tstop, event) ~ pspline(cd4) + prev_infection + sex + treatment, data = df_start_stop, x = TRUE)
summary(step_model_nonlin)
## Call:
## coxph(formula = Surv(tstart, tstop, event) ~ pspline(cd4) + prev_infection + 
##     sex + treatment, data = df_start_stop, x = TRUE)
## 
##   n= 1127, number of events= 157 
## 
##                      coef    se(coef) se2     Chisq DF   p      
## pspline(cd4), linear -0.1739 0.03006  0.02968 33.47 1.00 7.2e-09
## pspline(cd4), nonlin                           2.84 2.97 4.1e-01
## prev_infectionnoAIDS -0.9568 0.24358  0.24350 15.43 1.00 8.6e-05
## sexmale              -0.4374 0.25786  0.25778  2.88 1.00 9.0e-02
## treatmentddI          0.2839 0.16089  0.16086  3.11 1.00 7.8e-02
## 
##                      exp(coef) exp(-coef) lower .95 upper .95
## ps(cd4)3               0.60614     1.6498 1.326e-01    2.7712
## ps(cd4)4               0.37302     2.6808 6.520e-02    2.1341
## ps(cd4)5               0.25762     3.8817 4.985e-02    1.3313
## ps(cd4)6               0.21141     4.7302 3.973e-02    1.1250
## ps(cd4)7               0.10508     9.5168 1.808e-02    0.6107
## ps(cd4)8               0.04764    20.9900 7.307e-03    0.3106
## ps(cd4)9               0.03021    33.0984 4.041e-03    0.2259
## ps(cd4)10              0.02756    36.2813 2.965e-03    0.2562
## ps(cd4)11              0.02810    35.5899 1.720e-03    0.4591
## ps(cd4)12              0.02692    37.1474 5.283e-04    1.3716
## ps(cd4)13              0.02514    39.7783 8.698e-05    7.2655
## ps(cd4)14              0.02339    42.7550 8.290e-06   65.9911
## prev_infectionnoAIDS   0.38414     2.6032 2.383e-01    0.6192
## sexmale                0.64568     1.5487 3.895e-01    1.0703
## treatmentddI           1.32828     0.7529 9.690e-01    1.8207
## 
## Iterations: 2 outer, 8 Newton-Raphson
##      Theta= 0.5860794 
## Degrees of freedom for terms= 4 1 1 1 
## Concordance= 0.737  (se = 0.018 )
## Likelihood ratio test= 113.7  on 6.97 df,   p=<2e-16
autoplot(survfit(step_model_nonlin))

AIC(step_model_nonlin)
## [1] 1643.561
BIC(step_model_nonlin)
## [1] 1664.866
cox.zph(step_model_nonlin)
##                   chisq   df    p
## pspline(cd4)   2.152506 3.97 0.70
## prev_infection 0.081209 1.00 0.78
## sex            0.682539 1.00 0.41
## treatment      0.000277 1.00 0.99
## GLOBAL         3.011405 6.97 0.88

For non-linearity case, the chisq value low with a high p-value > 0.05, suggesting that a linear effect of cd4 is sufficient to explain its association with survival. In other words, the data does not provide strong evidence for a nonlinear relationship between cd4 and the hazard; so a simple linear term for cd4 might be sufficient.

Default random forest

set.seed(1)
# factor all column for random_forest
df2 <- data.frame(lapply(train_df, factor))
# except time and death 
df2$time <- train_df$time
df2$death <- train_df$death

head(df2)
##   subject  time death          cd4 time_obs treatment    sex prev_infection
## 1       3 18.53     1 3.4641016151        0       ddI female           AIDS
## 2       3 18.53     1 3.6055512755        2       ddI female           AIDS
## 3       3 18.53     1  6.164414003        6       ddI female           AIDS
## 4       4 12.70     0 3.8729833462        0       ddC   male           AIDS
## 5       4 12.70     0  4.582575695        2       ddC   male           AIDS
## 6       4 12.70     0 2.6457513111        6       ddC   male           AIDS
##           azt
## 1 intolerance
## 2 intolerance
## 3 intolerance
## 4     failure
## 5     failure
## 6     failure

Random Forest naturally diminishes the impact of unimportant variables, we will fit with all predictors.

rf_simple <- rfsrc(Surv(time, death) ~ ., data = df2)
summary(rf_simple)
##                Length Class      Mode     
## call                3 -none-     call     
## family              1 -none-     character
## n                   1 -none-     numeric  
## ntree               1 -none-     numeric  
## nimpute             1 -none-     numeric  
## mtry                1 -none-     numeric  
## nodesize            1 -none-     numeric  
## nodedepth           1 -none-     numeric  
## nsplit              1 -none-     numeric  
## yvar                2 data.frame list     
## yvar.names          2 -none-     character
## xvar                7 data.frame list     
## xvar.names          7 -none-     character
## event.info          7 -none-     list     
## subj                0 -none-     NULL     
## subj.names          0 -none-     NULL     
## xvar.wt             7 -none-     numeric  
## split.wt            7 -none-     numeric  
## cause.wt            1 -none-     numeric  
## leaf.count        500 -none-     numeric  
## proximity           0 -none-     NULL     
## forest             50 rfsrc      list     
## forest.wt           0 -none-     NULL     
## case.depth          0 -none-     NULL     
## distance            0 -none-     NULL     
## membership          0 -none-     NULL     
## tdc.membership      0 -none-     NULL     
## splitrule           1 -none-     character
## inbag               0 -none-     NULL     
## var.used            0 -none-     NULL     
## imputed.indv        0 -none-     NULL     
## imputed.data        0 -none-     NULL     
## split.depth         0 -none-     NULL     
## node.stats          0 -none-     NULL     
## ensemble            1 -none-     character
## holdout.array       0 -none-     NULL     
## block.size          1 -none-     numeric  
## holdout.blk         0 -none-     NULL     
## empr.risk           0 -none-     NULL     
## oob.empr.risk       0 -none-     NULL     
## ctime.internal      1 -none-     numeric  
## ctime.external      5 proc_time  numeric  
## chf            153272 -none-     numeric  
## chf.oob        153272 -none-     numeric  
## predicted        1127 -none-     numeric  
## predicted.oob    1127 -none-     numeric  
## hazard              0 -none-     NULL     
## hazard.oob          0 -none-     NULL     
## survival       153272 -none-     numeric  
## survival.oob   153272 -none-     numeric  
## cif                 0 -none-     NULL     
## cif.oob             0 -none-     NULL     
## err.rate          500 -none-     numeric  
## time.interest     136 -none-     numeric  
## ndead               1 -none-     numeric
cat(rf_simple$ntree, "\n")
## 500
cat(rf_simple$mtry, "\n")
## 3
cat(rf_simple$nodedepth)
## -1

Performance

Embedded or integraetd brier score

get_embeded_brier_score <- function(model, test_data) {
  # Calculate the Brier scores at multiple time points
  brier_res <- Score(
    object = list("Input Model" = model),  # Model to evaluate
    formula = Surv(time, death) ~ 1,  # Survival formula (specify the time and event variables)
    data = test_data,  # Test data for evaluation
    metrics = "brier",  # Calculate Brier score
    cens.model = "rfsrc"
  )
  return(brier_res$Brier$score$Brier[2]) #index 1 is null model
}
embedded_brier_lin <- get_embeded_brier_score(step_model, test_df)
print(paste("Embedded Brier Score for linear cox model:", embedded_brier_lin))
## [1] "Embedded Brier Score for linear cox model: 0.192297709257851"
embedded_brier_nonlin <- get_embeded_brier_score(step_model_nonlin, test_df)
print(paste("Embedded Brier Score for non-linear cox model:", embedded_brier_nonlin))
## [1] "Embedded Brier Score for non-linear cox model: 0.173106090369514"
embedded_brier_simple_rf <- get_embeded_brier_score(rf_simple, test_df)
print(paste("Embedded Brier Score for default random forest:", embedded_brier_simple_rf))
## [1] "Embedded Brier Score for default random forest: 0.153452104897629"
embedded_brier_simple_rf_opt <- get_embeded_brier_score(rf_opt, test_df)
print(paste("Embedded Brier Score for optimal random forest:", embedded_brier_simple_rf_opt))
## [1] "Embedded Brier Score for optimal random forest: 0.152302113724682"

Although the statistical test for nonlinearity is proved to be not significant, we can see that it has slightly better predictive performance than simple linear model.

Concordance index

#instruction: https://stat.ethz.ch/R-manual/R-devel/library/survival/html/concordance.html
p1 <- -predict(step_model)
p2 <- -predict(step_model_nonlin)
res_cindex <- concordance(Surv(tstart, tstop, event) ~ p1 + p2, df_start_stop)
res_cindex
## Call:
## concordance.formula(object = Surv(tstart, tstop, event) ~ p1 + 
##     p2, data = df_start_stop)
## 
## n= 1127 
##    concordance     se
## p1      0.7352 0.0179
## p2      0.7368 0.0178
## 
##    concordant discordant tied.x tied.y tied.xy
## p1      31857      11406    215     21       0
## p2      31925      11338    215     21       0
cat("\n")
print(paste("Cox linear Harrell's C-index:", res_cindex$concordance[1]))
## [1] "Cox linear Harrell's C-index: 0.735187911127467"
print(paste("Cox non-linear Harrell's C-index:", res_cindex$concordance[2]))
## [1] "Cox non-linear Harrell's C-index: 0.736751920511523"
#Paper: https://academic.oup.com/ije/article/45/5/1406/2450919?login=true
#discussion on C-index = 1 - get.cindex(): https://www.reddit.com/r/learnmachinelearning/comments/1cmf576/how_do_i_interpret_a_random_forest_survival/
#instruction: https://www.randomforestsrc.org/articles/survival.html
rf_simple_cindex = 1 - get.cindex(rf_simple$yvar[,1], rf_simple$yvar[,2], rf_simple$predicted.oob)
print(paste("Simple random forest Harrell's C-index:", rf_simple_cindex))
## [1] "Simple random forest Harrell's C-index: 0.784875838147177"
# Predict survival probabilities or risk scores from the model
#cfit <- concordance(Surv(df2$time, df2$death) ~ predict(rf_simple)$predicted + predict(opt_rf)$predicted + predict(step_model) + predict(step_model_nonlin))
#1 - cfit$concordance
rf_opt_cindex = 1 - get.cindex(rf_opt$yvar[,1], rf_opt$yvar[,2], rf_opt$predicted.oob)
print(paste("Calibrated random forest Harrell's C-index:", rf_opt_cindex))
## [1] "Calibrated random forest Harrell's C-index: 0.747992315792661"

Visual representation of performance

Brier score

# this return a dataframe for plot 
get_brier <- function(model){
  brier_results <- Score(
    object = list(model = model),  # Model to evaluate
    formula = Surv(time, death) ~ 1,  # Survival formula (specify the time and event variables)
    data = test_df,  # Test data for evaluation
    metrics = "brier",  # Calculate Brier score
    cens.model = "km",
    times=sort(unique(test_df$time)) # Sequence of times to evaluate Brier score
  )
  scores = tibble(brier_results$Brier$score)
  scores = scores %>% filter(model == "model")
  performances <- tibble(model = scores$Brier, times = scores$times)
  return(performances)
}
performances_df <- data.frame(
  # they have the same times
  times = get_brier(step_model)$times,
  cox = get_brier(step_model)$model,
  cox_non_lin = get_brier(step_model_nonlin)$model,
  rf_simple = get_brier(rf_simple)$model,
  rf_opt = get_brier(rf_opt)$model
)
# merge performance df
performances_long <- performances_df %>%
  pivot_longer(cols = c(cox, cox_non_lin, rf_simple, rf_opt),
               names_to = "model", 
               values_to = "brier_score")

ggplot(performances_long, aes(x = times, y = brier_score, color = model)) +
  geom_line() + # For line plot, you can change to geom_bar() for bar plot
  labs(title = "Model Performance Comparison",
       x = "Time", 
       y = "Brier score",
       color = "Model") +
  theme_gray() 

Survival curves

km_fit <- survfit(Surv(time, death) ~ 1, data=df)
kmi <- rep("Kaplan-Meier",length(km_fit$time))
km_df <- data.frame(km_fit$time, km_fit$surv, kmi)
names(km_df) <- c("Time","Surv","Model")

# survival curve for cox is derived from the fitted model using survfit(), so unlike forest model
cox_fit <- survfit(step_model)
coxi <- rep("Linear Cox",length(cox_fit$time))
cox_df <- data.frame(cox_fit$time,cox_fit$surv,coxi)
names(cox_df) <- c("Time","Surv","Model")

cox_nonlin_fit <- survfit(step_model_nonlin)
coxi <- rep("Non-linear Cox", length(cox_nonlin_fit$time))
cox_nonlin_df <- data.frame(cox_nonlin_fit$time, cox_nonlin_fit$surv, coxi)
names(cox_nonlin_df) <- c("Time","Surv","Model")

#RF-based survival models need predictions on a dataset (test or train) because survival probabilities are estimated for each individual and we combine these probabilities for the survival curve

rf_pred <- predict(rf_simple, newdata = test_df)
rf_time <- rf_pred$time.interest  # Extract time points
rf_surv <- apply(rf_pred$survival, 2, mean)  # Average survival probability across individuals
rfi <- rep("Random Forest", length(rf_time))  # Label for the model
rf_df <- data.frame(Time = rf_time, Surv = rf_surv, Model = rfi)

rf_opt_pred <- predict(rf_opt, newdata = test_df)
rf_opt_time <- rf_opt_pred$time.interest  # Extract time points
rf_opt_surv <- apply(rf_opt_pred$survival, 2, mean)  # Average survival probability across individuals (columns)
rfi_opt <- rep("Optimal Random Forest", length(rf_opt_time))  # Label for the model
rf_opt_df <- data.frame(Time = rf_opt_time, Surv = rf_opt_surv, Model = rfi_opt)

plot_df <- rbind(km_df, cox_df, cox_nonlin_df, rf_df, rf_opt_df)

main <- ggplot(plot_df, aes(x = Time, y = Surv, color = Model))
title <- labs(title = "Survival Curves of Various Models")
main + geom_line() + title

Aalen’s additive regression

aa_fit <- aareg(Surv(tstart, tstop, event) ~ . - subject, data = df_start_stop)
summary(aa_fit)
##                         slope      coef se(coef)      z        p
## Intercept             0.11600  0.008470 1.38e-03  6.130 8.65e-10
## treatmentddI          0.01310  0.000889 5.85e-04  1.520 1.28e-01
## sexmale              -0.02480 -0.001530 1.13e-03 -1.360 1.74e-01
## prev_infectionnoAIDS -0.02380 -0.001970 7.03e-04 -2.800 5.09e-03
## aztintolerance       -0.00893 -0.000826 8.77e-04 -0.943 3.46e-01
## cd4                  -0.00467 -0.000351 4.72e-05 -7.440 9.83e-14
## 
## Chisq=93.95 on 5 df, p=<2e-16; test weights=aalen

The plots show how the effects of the covariates change over time.

autoplot(aa_fit)

LTRCForest, ensemble methods

# https://cran.r-project.org/web/packages/LTRCforests/LTRCforests.pdf
df_start_stop_factor <- df_start_stop %>% 
  mutate(
    treatment = factor(treatment),
    sex = factor(sex),
    prev_infection = factor(prev_infection),
    azt = factor(azt)
    )

Formula = Surv(tstart, tstop, event) ~ cd4 + prev_infection + sex + treatment

Conditional inference forest

# define time-dependent and time-indepedent dataframes for time-merge
## time-independent does not have duplicate individual
df_time_ind <- test_df[!duplicated(test_df$subject), c("subject", "time", "death", "treatment", "sex", "prev_infection", "azt")]
df_time_dep <- test_df[, c("subject", "time_obs", "cd4")]

df_time_ind <- tmerge(df_time_ind, df_time_ind, id = subject, event = event(time, death))
test_df_start_stop <- tmerge(df_time_ind, df_time_dep, id = subject, cd4 = tdc(time_obs, cd4))

test_df_start_stop <- subset(test_df_start_stop, select = -c(time, death))
head(test_df_start_stop)
##   subject treatment  sex prev_infection         azt tstart tstop event
## 1       1       ddC male           AIDS intolerance      0  6.00     0
## 2       1       ddC male           AIDS intolerance      6 12.00     0
## 3       1       ddC male           AIDS intolerance     12 16.97     0
## 4       2       ddI male         noAIDS intolerance      0  6.00     0
## 5       2       ddI male         noAIDS intolerance      6 12.00     0
## 6       2       ddI male         noAIDS intolerance     12 18.00     0
##         cd4
## 1 10.677078
## 2  8.426150
## 3  9.433981
## 4  6.324555
## 5  8.124038
## 6  4.582576
LTRCCIFobj = ltrccif(formula = Formula, data = df_start_stop_factor)
## mtry =  2  OOB Brier score =  0.1723989 
## Searching left ...
## mtry =  1    OOB error =  0.1887881 
## Searching right ...
## mtry =  4    OOB error =  0.1748208 
## [1] "mtry is tuned to be 2"
# Time points
#tpnt = sort(unique(df_start_stop$tstop))
#Predobj = predictProb(LTRCCIFobj, time.eval = tpnt, newdata = test_df_start_stop, newdata.id = subject)
# Ensure tpnt is within the range of tau
#tau = seq(min(df_start_stop$tstop), max(df_start_stop$tstop), length.out = length(df_start_stop$tstop))
# Ensure you have the correct time points for prediction
#Predobj = predictProb(LTRCCIFobj, time.eval = tpnt, time.tau = tau)
Obj <- Surv(df_start_stop$tstart, df_start_stop$tstop, df_start_stop$event)
# Embedded 
#IBS = sbrier_ltrc(obj = Obj, pred = Predobj, type = "IBS")
## Compute the Brier score at each value of tpnt
#BS = sbrier_ltrc(obj = Obj, pred = Predobj, type = "BS")
## Plot the Brier scores
#plot(BS$Time, BS$BScore, pch = 20, xlab = "Time", ylab = "Brier score", col = 2)

Relative risk forest

Variable Importance (random forest)

smp <- subsample(rf_simple)
## no importance found: calculating it now ...
## done
## [                                                  ]   1%[█                                                 ]   2%[██                                                ]   3%[██                                                ]   4%[██                                                ]   5%[███                                               ]   6%[████                                              ]   7%[████                                              ]   8%[████                                              ]   9%[█████                                             ]  10%[██████                                            ]  11%[██████                                            ]  12%[██████                                            ]  13%[███████                                           ]  14%[████████                                          ]  15%[████████                                          ]  16%[████████                                          ]  17%[█████████                                         ]  18%[██████████                                        ]  19%[██████████                                        ]  20%[██████████                                        ]  21%[███████████                                       ]  22%[████████████                                      ]  23%[████████████                                      ]  24%[████████████                                      ]  25%[█████████████                                     ]  26%[██████████████                                    ]  27%[██████████████                                    ]  28%[██████████████                                    ]  29%[███████████████                                   ]  30%[████████████████                                  ]  31%[████████████████                                  ]  32%[████████████████                                  ]  33%[█████████████████                                 ]  34%[██████████████████                                ]  35%[██████████████████                                ]  36%[██████████████████                                ]  37%[███████████████████                               ]  38%[████████████████████                              ]  39%[████████████████████                              ]  40%[████████████████████                              ]  41%[█████████████████████                             ]  42%[██████████████████████                            ]  43%[██████████████████████                            ]  44%[██████████████████████                            ]  45%[███████████████████████                           ]  46%[████████████████████████                          ]  47%[████████████████████████                          ]  48%[████████████████████████                          ]  49%[█████████████████████████                         ]  50%[██████████████████████████                        ]  51%[██████████████████████████                        ]  52%[██████████████████████████                        ]  53%[███████████████████████████                       ]  54%[████████████████████████████                      ]  55%[████████████████████████████                      ]  56%[████████████████████████████                      ]  57%[█████████████████████████████                     ]  58%[██████████████████████████████                    ]  59%[██████████████████████████████                    ]  60%[██████████████████████████████                    ]  61%[███████████████████████████████                   ]  62%[████████████████████████████████                  ]  63%[████████████████████████████████                  ]  64%[████████████████████████████████                  ]  65%[█████████████████████████████████                 ]  66%[██████████████████████████████████                ]  67%[██████████████████████████████████                ]  68%[██████████████████████████████████                ]  69%[███████████████████████████████████               ]  70%[████████████████████████████████████              ]  71%[████████████████████████████████████              ]  72%[████████████████████████████████████              ]  73%[█████████████████████████████████████             ]  74%[██████████████████████████████████████            ]  75%[██████████████████████████████████████            ]  76%[██████████████████████████████████████            ]  77%[███████████████████████████████████████           ]  78%[████████████████████████████████████████          ]  79%[████████████████████████████████████████          ]  80%[████████████████████████████████████████          ]  81%[█████████████████████████████████████████         ]  82%[██████████████████████████████████████████        ]  83%[██████████████████████████████████████████        ]  84%[██████████████████████████████████████████        ]  85%[███████████████████████████████████████████       ]  86%[████████████████████████████████████████████      ]  87%[████████████████████████████████████████████      ]  88%[████████████████████████████████████████████      ]  89%[█████████████████████████████████████████████     ]  90%[██████████████████████████████████████████████    ]  91%[██████████████████████████████████████████████    ]  92%[██████████████████████████████████████████████    ]  93%[███████████████████████████████████████████████   ]  94%[████████████████████████████████████████████████  ]  95%[████████████████████████████████████████████████  ]  96%[████████████████████████████████████████████████  ]  97%[█████████████████████████████████████████████████ ]  98%[██████████████████████████████████████████████████]  99%[██████████████████████████████████████████████████] 100%                                                            
# two events of death status so target = 2
# resize plot to fit variable names
par(mar = c(5, 8, 4, 2))
plot.subsample(smp, target = 2, xlab = "Variable Importance") 

Nothing new, prev_infection is important, however, for forest based model, \(azt\) should be considered.

Synthetic profile and scenario analysis

Since there are only two levels for each categorical variable, we construct a new data frame one for each value and the other covariates are fixed as below:

# define mean and mode respectively
cd4_mean <- mean(df$cd4)
treatment_mode <- Mode(df$treatment)[1] #value of [1] index
azt_mode <- Mode(df$azt)[1]
previnfection_mode <- Mode(df$prev_infection)[1]
sex_mode <- Mode(df$sex)[1]

We will fit a full model with all relevant predictors, even if some are less significant statistically. This will assess the survival probabilities comprehensively for various sets of covariates.

cox_all <- coxph(formula = Surv(tstart, tstop, event) ~ cd4 + prev_infection + azt + sex + treatment, data = df_start_stop, x = TRUE)

sex impact

Consider that, we want to assess the impact of the sex on the estimated survival probability beyond 18 months.

sex_df <- with(df,data.frame(sex = unique(df$sex),
                             cd4 = rep(cd4_mean, 2),
                             treatment = rep(treatment_mode, 2), 
                             azt = rep(azt_mode, 2),
                             prev_infection = rep(previnfection_mode, 2)
                             )
                          )
sex_df
##      sex      cd4 treatment         azt prev_infection
## 1   male 7.022919       ddC intolerance           AIDS
## 2 female 7.022919       ddC intolerance           AIDS
sex_fit <- survfit(cox_all, newdata = sex_df)
ggsurvplot(sex_fit, conf.int = TRUE, legend.labs=unique(df$sex),
           ggtheme = theme_minimal(), data = sex_df)

summary(sex_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = sex_df)
## 
##  time n.risk n.event survival1 survival2
##    18     47     154     0.647     0.503

sex does not differ the survival probability, they are exactly equal.

treatment impact

Consider that, we want to assess the impact of the treatment on the estimated survival probability beyond 18 months.

treatment_df <- with(df,data.frame(sex = rep(sex_mode, 2),
                             cd4 = rep(cd4_mean, 2),
                             treatment = unique(df$treatment), 
                             azt = rep(azt_mode, 2),
                             prev_infection = rep(previnfection_mode, 2)
                             )
                          )
treatment_df
##    sex      cd4 treatment         azt prev_infection
## 1 male 7.022919       ddC intolerance           AIDS
## 2 male 7.022919       ddI intolerance           AIDS
treatment_fit <- survfit(cox_all, newdata = treatment_df)
ggsurvplot(treatment_fit, conf.int = TRUE,ggtheme = theme_minimal(), data = treatment_df, legend.labs=unique(df$treatment))

summary(treatment_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = treatment_df)
## 
##  time n.risk n.event survival1 survival2
##    18     47     154     0.647     0.558

ddC treatment has better surival rate than ddI treatment group.

prev_infection impact

prev_inf_df <- with(df,data.frame(sex = rep(sex_mode, 2),
                             cd4 = rep(cd4_mean, 2),
                             treatment = rep(treatment_mode, 2), 
                             azt = rep(azt_mode, 2),
                             prev_infection = unique(df$prev_infection)
                             )
                    )
print(prev_inf_df)
##    sex      cd4 treatment         azt prev_infection
## 1 male 7.022919       ddC intolerance           AIDS
## 2 male 7.022919       ddC intolerance         noAIDS
prev_inf_fit <- survfit(cox_all, newdata = prev_inf_df)
ggsurvplot(prev_inf_fit, conf.int = TRUE, ggtheme = theme_minimal(), data = prev_inf_df, legend.labs=unique(df$prev_infection))

summary(prev_inf_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = prev_inf_df)
## 
##  time n.risk n.event survival1 survival2
##    18     47     154     0.647     0.837

previous infection strongly impacts the survival rate since those with noAIDS infection have higher probability 0.827 > 0.608.

azt impact

azt_df <- with(df,data.frame(sex = rep(sex_mode, 2),
                             cd4 = rep(cd4_mean, 2),
                             treatment = rep(treatment_mode, 2), 
                             azt = unique(df$azt),
                             prev_infection = rep(previnfection_mode, 2)
                             )
                    )
print(azt_df)
##    sex      cd4 treatment         azt prev_infection
## 1 male 7.022919       ddC intolerance           AIDS
## 2 male 7.022919       ddC     failure           AIDS
azt_fit <- survfit(cox_all, newdata = azt_df)
ggsurvplot(azt_fit, conf.int = TRUE, ggtheme = theme_minimal(), data = azt_df, legend.labs=unique(df$azt))

summary(azt_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = azt_df)
## 
##  time n.risk n.event survival1 survival2
##    18     47     154     0.647     0.605

No difference whether they were previously fail or intolerance to azt therapy.

azt_df <- with(df,data.frame(sex = c("male", "female"),
                             cd4 = rep(cd4_mean, 2),
                             treatment = rep(treatment_mode, 2), 
                             azt = unique(df$azt),
                             prev_infection = rep(previnfection_mode, 2)
                             )
                    )
print(azt_df)
##      sex      cd4 treatment         azt prev_infection
## 1   male 7.022919       ddC intolerance           AIDS
## 2 female 7.022919       ddC     failure           AIDS
azt_fit <- survfit(cox_all, newdata = azt_df)
ggsurvplot(azt_fit, conf.int = TRUE, ggtheme = theme_minimal(), data = azt_df, legend.labs=unique(df$azt))

summary(azt_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = azt_df)
## 
##  time n.risk n.event survival1 survival2
##    18     47     154     0.647     0.452

cd4 impact

cd4_df <- with(df,data.frame(sex = rep(sex_mode, 3),
                             cd4 = c(1, mean(df$cd4), 15),
                             treatment = rep(treatment_mode, 3), 
                             azt = rep(azt_mode, 3),
                             prev_infection = rep(previnfection_mode, 3)
                             )
                    )
print(cd4_df)
##    sex       cd4 treatment         azt prev_infection
## 1 male  1.000000       ddC intolerance           AIDS
## 2 male  7.022919       ddC intolerance           AIDS
## 3 male 15.000000       ddC intolerance           AIDS
cd4_fit <- survfit(cox_all, newdata = cd4_df)
ggsurvplot(cd4_fit, conf.int = TRUE, ggtheme = theme_minimal(), data = cd4_df, legend.labs=c("Low", "Medium", "High"))

summary(cd4_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = cd4_df)
## 
##  time n.risk n.event survival1 survival2 survival3
##    18     47     154     0.286     0.647     0.898

cd4 cell count has huge impact on survival probability.

Mixed impact

There are many possibilities to vary covariates. We will do it intuitively based on information we have so far from the analysis. Information we have so far from synthetic data:

  • male has slightly better survival rate than female.
  • ddC is more effective than ddI.
  • intolerance people have slightly better survival rate than failure.
  • cd4 and prev_infection has huge impact.
#mixed_df <- with(df,data.frame(sex = c("male", "male", "female"),
#                            cd4 = c(mean(df$cd4), 10, 10),
#                             treatment = c("ddC", "ddC", "ddC"), 
#                             azt = c("intolerance", "failure", "intolerance"),
#                            prev_infection = c("noAIDS", "noAIDS", "noAIDS")
#                             )
#                    )
mixed_df <- with(df,data.frame(sex = c("male", "male", "female"),
                             cd4 = c(1, 7, 15),
                             treatment = c("ddC", "ddC", "ddC"), 
                             azt = c("intolerance", "intolerance", "intolerance"),
                             prev_infection = c("AIDS", "AIDS", "AIDS")
                             )
                    )
print(mixed_df)
##      sex cd4 treatment         azt prev_infection
## 1   male   1       ddC intolerance           AIDS
## 2   male   7       ddC intolerance           AIDS
## 3 female  15       ddC intolerance           AIDS
mixed_fit <- survfit(cox_all, newdata = mixed_df)
ggsurvplot(mixed_fit, conf.int = TRUE, ggtheme = theme_minimal(), data = mixed_df, legend.labs=c("Low", "Medium", "High"))

summary(mixed_fit, times = 18)
## Call: survfit(formula = cox_all, newdata = mixed_df)
## 
##  time n.risk n.event survival1 survival2 survival3
##    18     47     154     0.286     0.646     0.844

By varying different set covariates manually (I do not put the code for each case since it will take too much space), we can confirm that:

  • ddC is unconditionally always better than ddI, does not matter if a subject is male/female, fail or tolerate AZT, previously infected or not.
  • cd4 and prev_infection still have a lot of say in survival probability. However, theoratically, if a subject were to have high cd4 and previously got infected, he/she will likely to surivive after 18 months. Though it is not common, but we can assume that cd4 is the most powerful predictor.
  • With the same cd4, same treatment, same infection condition, even though a male failed the azt therapy, he will have survival probability than female that did not fail (intolerance).

Conditional probability

For simplicity, we work on an individual with intolerance condition toward AZT therapy.

prev_inf_df <- with(df,data.frame(sex = rep(sex_mode, 1),
                             cd4 = rep(cd4_mean, 1),
                             treatment = rep(treatment_mode, 1), 
                             azt = rep(azt_mode, 1),
                             prev_infection = unique(df$prev_infection)[1]
                             )
                    )
print(prev_inf_df)
##    sex      cd4 treatment         azt prev_infection
## 1 male 7.022919       ddC intolerance           AIDS
prev_inf_fit <- survfit(step_model, newdata = prev_inf_df)
ggsurvplot(prev_inf_fit, conf.int = TRUE, ggtheme = theme_minimal(), data = prev_inf_df, legend.labs=unique(df$prev_infection)[1])

cat("+++++++++++++++++++++++ Survival rate after 12 months +++++++++++++++++++++++ \n\n")
## +++++++++++++++++++++++ Survival rate after 12 months +++++++++++++++++++++++
summary(prev_inf_fit, times = 12)
## Call: survfit(formula = step_model, newdata = prev_inf_df)
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##    12    249     124    0.738  0.0376        0.668        0.816
cat("\n")
cat("+++++++++++++++++++++++ Survival rate after 18 months +++++++++++++++++++++++ \n\n")
## +++++++++++++++++++++++ Survival rate after 18 months +++++++++++++++++++++++
summary(prev_inf_fit, times = 18)
## Call: survfit(formula = step_model, newdata = prev_inf_df)
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##    18     47     154    0.622  0.0507         0.53         0.73
cat("+++++++++++++++++++++++ Survival rate knowing that patient survives for 12 months +++++++++++++++++++++++ \n")
## +++++++++++++++++++++++ Survival rate knowing that patient survives for 12 months +++++++++++++++++++++++
summary(prev_inf_fit, times = 18)$surv / summary(prev_inf_fit, times = 12)$surv
## [1] 0.8423706

We can see that the probability of survival has increased because by knowing that the subject has already survived for 12 months, meaning the treatment progresses well. Hence, it is logic both theoretically and practically that it goes higher.